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 0f93be75eecef03163089b7358f8673a16190a9b..78e7ed77b454e990b7a06350fcbb2fb92f7b57f1 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 5bc8394222b976c6e56a7be513821b27ef7f9a73..52a927e46004c328a1752a83daeeb49e600b49df 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 8de596e4f6ec0ff101079814c97ae6c75dacbbb9..a311de017fb9f0aee6673e92b1282a8b4984da5d 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 = {};