diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/conversion.cpp | 12 |
3 files changed, 10 insertions, 6 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index b4fd66d592..1efa4f2f17 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1731,7 +1731,7 @@ def warn_impcast_bool_to_null_pointer : Warning< "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'">, diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index f00a655f59..cd24a4f459 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -4076,7 +4076,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, 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; } diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp index d9ba07ab5b..9e0950634d 100644 --- a/test/SemaCXX/conversion.cpp +++ b/test/SemaCXX/conversion.cpp @@ -57,11 +57,15 @@ namespace test2 { // 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'}} } |