On Wednesday 14 of March 2012, David Blaikie wrote:
> On Tue, Mar 13, 2012 at 10:53 PM, Lubos Lunak <[email protected]> wrote:
> > Updated patch attached.
>
> Great - I have two optional suggestions
>
> * You can remove the stddef.h include from test/SemaCXX/conversion.cpp
Done, attached.
> * You could change the NULL usage in conversion-gnunull.cpp to __null
> & drop the header to simplify/isolate the test case a bit further.
> (this is, perhaps, debatable - as it doesn't quite test the "real" use
> case)
I've left this one as it is. I don't expect the header to break things and
NULL is what people use in real programs, so in case it actually breaks, it's
probably better to trigger it here too.
> and one question I can't answer that blocks me from signing
> off/checking this in for you:
>
> Is the change in lib/Driver/Tools.cpp necessary/correct? I don't fully
> understand what this list is for. Chandler helped me/speculated that
> this is a list of all Clang options that don't exist in GCC 4.2 - but
> if that's the case it's already broken (even by changes I've made -
> such as adding the -Wcovered-switch-default flag which I never added
> to this list). So I'm wondering where this list is tested/validated.
> Hopefully an Apple Clang developer can chime in here & explain this.
I have no idea, obviously. I only followed usage of another conversion
option. All I can say is that when removing this change passing
-Wno-conversion-null still disables the warning.
--
Lubos Lunak
[email protected]
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index 26dcc40..9baa276 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -28,6 +28,7 @@ def Availability : DiagGroup<"availability">;
def AutoImport : DiagGroup<"auto-import">;
def BoolConversions : DiagGroup<"bool-conversions">;
def IntConversions : DiagGroup<"int-conversions">;
+def ConversionNull : DiagGroup<"conversion-null">;
def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">;
def CXXCompat: DiagGroup<"c++-compat">;
def CastAlign : DiagGroup<"cast-align">;
@@ -282,6 +283,7 @@ def Parentheses : DiagGroup<"parentheses",
// - conversion warnings with constant sources are on by default
// - conversion warnings for literals are on by default
// - bool-to-pointer conversion warnings are on by default
+// - __null-to-integer conversion warnings are on by default
def Conversion : DiagGroup<"conversion",
[DiagGroup<"shorten-64-to-32">,
DiagGroup<"constant-conversion">,
@@ -289,7 +291,8 @@ def Conversion : DiagGroup<"conversion",
DiagGroup<"string-conversion">,
DiagGroup<"sign-conversion">,
BoolConversions,
- IntConversions]>,
+ IntConversions,
+ ConversionNull]>,
DiagCategory<"Value Conversion Issue">;
def Unused : DiagGroup<"unused",
@@ -325,6 +328,7 @@ def Extra : DiagGroup<"extra", [
def Most : DiagGroup<"most", [
CharSubscript,
Comment,
+ ConversionNull,
DeleteNonVirtualDtor,
Format,
Implicit,
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index d859f37..de9558e 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1733,7 +1733,7 @@ def warn_impcast_bool_to_null_pointer : Warning<
"expression">, InGroup<BoolConversions>;
def warn_impcast_null_pointer_to_integer : Warning<
"implicit conversion of NULL constant to integer">,
- InGroup<DiagGroup<"conversion">>, DefaultIgnore;
+ InGroup<ConversionNull>;
def warn_impcast_function_to_bool : Warning<
"address of function %q0 will always evaluate to 'true'">,
InGroup<BoolConversions>;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 780016a..536897f 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -3168,6 +3168,7 @@ void darwin::CC1::RemoveCC1UnsupportedArgs(ArgStringList &CmdArgs) const {
.Case("c++11-narrowing", true)
.Case("conditional-uninitialized", true)
.Case("constant-conversion", true)
+ .Case("conversion-null", true)
.Case("CFString-literal", true)
.Case("constant-logical-operand", true)
.Case("custom-atomic-properties", true)
diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp
index 3f2bac1..b1f4962 100644
--- a/test/Analysis/nullptr.cpp
+++ b/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/test/SemaCXX/__null.cpp b/test/SemaCXX/__null.cpp
index 1989a45..08d9960 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-conversion-null -fsyntax-only -verify
+// RUN: %clang_cc1 -triple i686-unknown-unknown %s -Wno-conversion-null -fsyntax-only -verify
void f() {
int* i = __null;
diff --git a/test/SemaCXX/conversion-gnunull.cpp b/test/SemaCXX/conversion-gnunull.cpp
new file mode 100644
index 0000000..8516c88
--- /dev/null
+++ b/test/SemaCXX/conversion-gnunull.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
+
+#include <stddef.h>
+
+// This file tests -Wconversion-null, 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; 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}}
+}
diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp
index b069abc..fdda7ac 100644
--- a/test/SemaCXX/conversion.cpp
+++ b/test/SemaCXX/conversion.cpp
@@ -1,7 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s
-#include <stddef.h>
-
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
@@ -52,12 +50,3 @@ namespace test2 {
A() : x(10) {} // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
};
}
-
-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}}
- 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}}
-}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits