From: Paolo Carlini Date: Tue, 10 Apr 2018 22:34:06 +0000 (+0000) Subject: re PR c++/70808 (Spurious -Wzero-as-null-pointer-constant for nullptr_t) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=310e77fe20f20da1cfcb6adb44ac52ccd127ed58;p=gcc.git re PR c++/70808 (Spurious -Wzero-as-null-pointer-constant for nullptr_t) /cp 2018-04-10 Paolo Carlini 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 PR c++/70808 * g++.dg/warn/Wzero-as-null-pointer-constant-7.C: New. From-SVN: r259303 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0f93be75eec..78e7ed77b45 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-10 Paolo Carlini + + 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 PR debug/65821 - wrong location for main(). diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5bc8394222b..52a927e4600 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8de596e4f6e..a311de017fb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-10 Paolo Carlini + + PR c++/70808 + * g++.dg/warn/Wzero-as-null-pointer-constant-7.C: New. + 2018-04-10 Segher Boessenkool * 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 index 00000000000..808b85ba8c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C @@ -0,0 +1,5 @@ +// PR c++/70808 +// { dg-options "-Wzero-as-null-pointer-constant" } + +int* no_warn = {}; +decltype( nullptr ) warn = {};