Core 903
authorJason Merrill <jason@redhat.com>
Wed, 21 Sep 2016 19:49:32 +0000 (15:49 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 21 Sep 2016 19:49:32 +0000 (15:49 -0400)
Core 903
* call.c (null_ptr_cst_p): Check char_type_p.

From-SVN: r240329

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/nullptr36.C [new file with mode: 0644]

index 6bafde59893a3194843c0e110163414409a97897..61d41e739ad4e78f48b1212bf0b77850306fb470 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-21  Jason Merrill  <jason@redhat.com>
+
+       Core 903
+       * call.c (null_ptr_cst_p): Check char_type_p.
+
 2016-09-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/77651
index b6f65d2fe0503362d472102bc6e0cb3902bac254..c236580210362eeff338b60260e08946c882115d 100644 (file)
@@ -527,6 +527,7 @@ null_ptr_cst_p (tree t)
     {
       /* Core issue 903 says only literal 0 is a null pointer constant.  */
       if (TREE_CODE (type) == INTEGER_TYPE
+         && !char_type_p (type)
          && TREE_CODE (t) == INTEGER_CST
          && integer_zerop (t)
          && !TREE_OVERFLOW (t))
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr36.C b/gcc/testsuite/g++.dg/cpp0x/nullptr36.C
new file mode 100644 (file)
index 0000000..5f43881
--- /dev/null
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++11 } }
+
+void *p = '\0';                        // { dg-error "invalid conversion" }