summaryrefslogtreecommitdiff
path: root/clang/test
diff options
context:
space:
mode:
authorKristina Brooks <kristina@nym.hush.com>2019-01-14 18:16:51 +0000
committerKristina Brooks <kristina@nym.hush.com>2019-01-14 18:16:51 +0000
commit6c5ad1bdeb29f6601f258570826e8d670a20a60e (patch)
tree0d6a77416c1d49187c4a22b9f007dbc524ed674a /clang/test
parent100b918213098664dc8497b7b356c17142ec65c1 (diff)
[Sema] Expose a control flag for integer to pointer ext warning
While building openJDK11u, it seems that some of the code in the native core libraries make liberal use of integer to pointer comparisons. We currently have no flag to disabled this warning. This add such a flag. Patch by Kader (abdoul-kader keita) Differential Revision: https://reviews.llvm.org/D56241
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Misc/warning-flags.c3
-rw-r--r--clang/test/Sema/ext-typecheck-comparison-of-pointer-integer.c12
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index b7867591039..05172b22085 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (75):
+CHECK: Warnings without flags (74):
CHECK-NEXT: ext_excess_initializers
CHECK-NEXT: ext_excess_initializers_in_char_array_initializer
CHECK-NEXT: ext_expected_semi_decl_list
@@ -29,7 +29,6 @@ CHECK-NEXT: ext_missing_whitespace_after_macro_name
CHECK-NEXT: ext_new_paren_array_nonconst
CHECK-NEXT: ext_plain_complex
CHECK-NEXT: ext_template_arg_extra_parens
-CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer
CHECK-NEXT: ext_typecheck_cond_incompatible_operands
CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer
CHECK-NEXT: ext_using_undefined_std
diff --git a/clang/test/Sema/ext-typecheck-comparison-of-pointer-integer.c b/clang/test/Sema/ext-typecheck-comparison-of-pointer-integer.c
new file mode 100644
index 00000000000..b928156aff2
--- /dev/null
+++ b/clang/test/Sema/ext-typecheck-comparison-of-pointer-integer.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify -DEXPECTWARNING %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify -Wno-pointer-integer-compare %s
+
+#ifdef EXPECTWARNING
+// expected-warning@+6 {{comparison between pointer and integer ('int' and 'int *')}}
+#else
+// expected-no-diagnostics
+#endif
+
+int test_ext_typecheck_comparison_of_pointer_integer(int integer, int * pointer) {
+ return integer != pointer;
+}