diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-04-27 22:29:12 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-04-27 22:29:12 +0200 |
commit | b2b1ea3455979699f172e1601785efa57e3cd3f2 (patch) | |
tree | 71f0dd1ef271f4cf3f3768b6ba3cb0ae33ed8648 /gcc | |
parent | 3b67d7e6949d199a0aadf866734332374a3eced9 (diff) | |
download | gcc-b2b1ea3455979699f172e1601785efa57e3cd3f2.zip gcc-b2b1ea3455979699f172e1601785efa57e3cd3f2.tar.gz gcc-b2b1ea3455979699f172e1601785efa57e3cd3f2.tar.bz2 |
re PR c++/85553 (cannot list-initialize a variable of type std::nullptr_t)
PR c++/85553
* init.c (build_zero_init_1): For zero initialization of
NULLPTR_TYPE_P type use build_int_cst directly.
* g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C: Add dg-bogus
directive.
* g++.dg/cpp0x/constexpr-85553.C: New test.
From-SVN: r259728
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C | 4 |
5 files changed, 21 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d8e7089..6253c9b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/85553 + * init.c (build_zero_init_1): For zero initialization of + NULLPTR_TYPE_P type use build_int_cst directly. + 2018-04-27 David Malcolm <dmalcolm@redhat.com> PR c++/85515 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 52a927e..d6c0bcf 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -180,8 +180,10 @@ 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) || NULLPTR_TYPE_P (type)) + else if (TYPE_PTR_OR_PTRMEM_P (type)) init = fold (convert (type, nullptr_node)); + else if (NULLPTR_TYPE_P (type)) + init = build_int_cst (type, 0); else if (SCALAR_TYPE_P (type)) init = fold (convert (type, integer_zero_node)); else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce5eaba..9002abf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-04-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/85553 + * g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C: Add dg-bogus + directive. + * g++.dg/cpp0x/constexpr-85553.C: New test. + 2018-04-27 David Malcolm <dmalcolm@redhat.com> PR c++/85515 diff --git a/gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C b/gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C index b03ec94..3e471aa 100644 --- a/gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C +++ b/gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C @@ -3,4 +3,4 @@ // { dg-options "-Wzero-as-null-pointer-constant" } int* no_warn = {}; -decltype( nullptr ) warn = {}; +decltype( nullptr ) warn = {}; // { dg-bogus "zero as null pointer constant" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C new file mode 100644 index 0000000..3c6d3c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C @@ -0,0 +1,4 @@ +// PR c++/85553 +// { dg-do compile { target c++11 } } +using T = decltype(nullptr); +const constexpr T foo{}; |