Author: dblaikie
Date: Thu Mar 15 15:48:26 2012
New Revision: 152835

URL: http://llvm.org/viewvc/llvm-project?rev=152835&view=rev
Log:
Provide the specific target type in the -Wnull-conversion warning.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaCXX/conversion.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=152835&r1=152834&r2=152835&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar 15 15:48:26 
2012
@@ -1731,7 +1731,7 @@
     "initialization of pointer of type %0 to null from a constant boolean "
     "expression">, InGroup<BoolConversion>;
 def warn_impcast_null_pointer_to_integer : Warning<
-    "implicit conversion of NULL constant to integer">,
+    "implicit conversion of NULL constant to %0">,
     InGroup<NullConversion>;
 def warn_impcast_function_to_bool : Warning<
     "address of function %q0 will always evaluate to 'true'">,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=152835&r1=152834&r2=152835&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Mar 15 15:48:26 2012
@@ -4076,7 +4076,7 @@
   if ((E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)
            == Expr::NPCK_GNUNull) && Target->isIntegerType()) {
     S.Diag(E->getExprLoc(), diag::warn_impcast_null_pointer_to_integer)
-        << E->getSourceRange() << clang::SourceRange(CC);
+        << T << E->getSourceRange() << clang::SourceRange(CC);
     return;
   }
 

Modified: cfe/trunk/test/SemaCXX/conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion.cpp?rev=152835&r1=152834&r2=152835&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion.cpp Thu Mar 15 15:48:26 2012
@@ -57,11 +57,15 @@
 // which is on by default.
 
 void test3() {
-  int a = NULL; // expected-warning {{implicit conversion of NULL constant to 
integer}}
+  int a = NULL; // expected-warning {{implicit conversion of NULL constant to 
'int'}}
   int b;
-  b = NULL; // expected-warning {{implicit conversion of NULL constant to 
integer}}
+  b = NULL; // expected-warning {{implicit conversion of NULL constant to 
'int'}}
   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 c = ((((NULL)))); // expected-warning {{implicit conversion of NULL 
constant to 'int'}}
   int d;
-  d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant 
to integer}}
+  d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant 
to 'int'}}
+  bool bl = NULL; // FIXME: this should warn but we currently suppress a bunch 
of conversion-to-bool warnings including this one
+  char ch = NULL; // expected-warning {{implicit conversion of NULL constant 
to 'char'}}
+  unsigned char uch = NULL; // expected-warning {{implicit conversion of NULL 
constant to 'unsigned char'}}
+  short sh = NULL; // expected-warning {{implicit conversion of NULL constant 
to 'short'}}
 }


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to