summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-03-15 04:50:32 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-03-15 04:50:32 +0000
commit95187bdd5c955c8edf3527eae41f1e4f80377f27 (patch)
treec8917da28b1f293a92634cfaf15599123e7ee0fb /test/SemaCXX
parent7267839dc2fe8ec16445081c3b740ffda5ead217 (diff)
Reapply r152745 (reverted in 152765) now that compiler-rt is fixed.
Original commit message: Provide -Wnull-conversion separately from -Wconversion. Like GCC, provide a NULL conversion to non-pointer conversion as a separate flag, on by default. GCC's flag is "conversion-null" which we provide for cross compatibility, but in the interests of consistency (with -Wint-conversion, -Wbool-conversion, etc) the canonical Clang flag is called -Wnull-conversion. Patch by Lubos Lunak. Review feedback by myself, Chandler Carruth, and Chad Rosier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152774 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/__null.cpp4
-rw-r--r--test/SemaCXX/conversion.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/test/SemaCXX/__null.cpp b/test/SemaCXX/__null.cpp
index 1989a45fb5..56e59c06f1 100644
--- a/test/SemaCXX/__null.cpp
+++ b/test/SemaCXX/__null.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify
-// RUN: %clang_cc1 -triple i686-unknown-unknown %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -Wno-null-conversion -fsyntax-only -verify
+// RUN: %clang_cc1 -triple i686-unknown-unknown %s -Wno-null-conversion -fsyntax-only -verify
void f() {
int* i = __null;
diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp
index b069abc263..d9ba07ab5b 100644
--- a/test/SemaCXX/conversion.cpp
+++ b/test/SemaCXX/conversion.cpp
@@ -53,10 +53,14 @@ namespace test2 {
};
}
+// This file tests -Wnull-conversion, a subcategory of -Wconversion
+// which is on by default.
+
void test3() {
int a = NULL; // expected-warning {{implicit conversion of NULL constant to integer}}
int b;
b = NULL; // expected-warning {{implicit conversion of NULL constant to integer}}
+ long l = NULL; // FIXME: this should also warn, but currently does not if sizeof(NULL)==sizeof(inttype)
int c = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to integer}}
int d;
d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to integer}}