diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-03-14 22:28:22 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-03-14 22:28:22 +0000 |
commit | 47bfaf19ddc980a9eb48f2978f4da9b7861b9cda (patch) | |
tree | 6ad0bb8f92cbae6212f09659459828ae2e722752 /test/SemaCXX | |
parent | 10cde2fc0c1804427dd3e0c050c149ac6d415f51 (diff) |
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@152745 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r-- | test/SemaCXX/__null.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/conversion.cpp | 4 |
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}} |