re PR c++/70808 (Spurious -Wzero-as-null-pointer-constant for nullptr_t)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 10 Apr 2018 22:34:06 +0000 (22:34 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 10 Apr 2018 22:34:06 +0000 (22:34 +0000)
/cp
2018-04-10  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70808
* init.c (build_zero_init_1): Handle NULLPTR_TYPE_P being true of
the type like TYPE_PTR_OR_PTRMEM_P.

/testsuite
2018-04-10  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70808
* g++.dg/warn/Wzero-as-null-pointer-constant-7.C: New.

From-SVN: r259303

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C [new file with mode: 0644]

index 0f93be7..78e7ed7 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-10  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70808
+       * init.c (build_zero_init_1): Handle NULLPTR_TYPE_P being true of
+       the type like TYPE_PTR_OR_PTRMEM_P.
+
 2018-04-10  Jason Merrill  <jason@redhat.com>
 
        PR debug/65821 - wrong location for main().
index 5bc8394..52a927e 100644 (file)
@@ -180,7 +180,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
        items with static storage duration that are not otherwise
        initialized are initialized to zero.  */
     ;
-  else if (TYPE_PTR_OR_PTRMEM_P (type))
+  else if (TYPE_PTR_OR_PTRMEM_P (type) || NULLPTR_TYPE_P (type))
     init = fold (convert (type, nullptr_node));
   else if (SCALAR_TYPE_P (type))
     init = fold (convert (type, integer_zero_node));
index 8de596e..a311de0 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-10  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70808
+       * g++.dg/warn/Wzero-as-null-pointer-constant-7.C: New.
+
 2018-04-10  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * gcc.target/powerpc/dfmode_off.c: Add -fno-asynchronous-unwind-tables.
diff --git a/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C b/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C
new file mode 100644 (file)
index 0000000..808b85b
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/70808
+// { dg-options "-Wzero-as-null-pointer-constant" }
+
+int* no_warn = {};
+decltype( nullptr ) warn = {};