diff options
| author | David Blaikie <dblaikie@gmail.com> | 2012-03-15 04:50:32 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2012-03-15 04:50:32 +0000 |
| commit | ebcbe4b6aaee94d3a1104f86d5771cee151da4bd (patch) | |
| tree | 44e9a26ba1a9f7a9c9ec4b2d0769bc156cc0b360 /clang/test | |
| parent | e059c124a8dc649ebcd8e602a71dd6f31635d7d0 (diff) | |
| download | bcm5719-llvm-ebcbe4b6aaee94d3a1104f86d5771cee151da4bd.tar.gz bcm5719-llvm-ebcbe4b6aaee94d3a1104f86d5771cee151da4bd.zip | |
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.
llvm-svn: 152774
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/nullptr.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/__null.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/conversion.cpp | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/clang/test/Analysis/nullptr.cpp b/clang/test/Analysis/nullptr.cpp index c0fed872428..3119b4fc390 100644 --- a/clang/test/Analysis/nullptr.cpp +++ b/clang/test/Analysis/nullptr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core -analyzer-store region -verify %s +// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core -analyzer-store region -verify %s // test to see if nullptr is detected as a null pointer void foo1(void) { diff --git a/clang/test/SemaCXX/__null.cpp b/clang/test/SemaCXX/__null.cpp index 1989a45fb5f..56e59c06f16 100644 --- a/clang/test/SemaCXX/__null.cpp +++ b/clang/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/clang/test/SemaCXX/conversion.cpp b/clang/test/SemaCXX/conversion.cpp index b069abc263f..d9ba07ab5b5 100644 --- a/clang/test/SemaCXX/conversion.cpp +++ b/clang/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}} |

