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
This commit is contained in:
Jakub Jelinek 2018-04-27 22:29:12 +02:00 committed by Jakub Jelinek
parent 3b67d7e694
commit b2b1ea3455
5 changed files with 21 additions and 2 deletions

View File

@ -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

View File

@ -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)))

View File

@ -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

View File

@ -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" }

View File

@ -0,0 +1,4 @@
// PR c++/85553
// { dg-do compile { target c++11 } }
using T = decltype(nullptr);
const constexpr T foo{};