From 736a933c00ff57c2631bae3d1eeeacd73faf003c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 20 Feb 2017 01:06:03 -0500 Subject: [PATCH] PR c++/79607 - ICE with T{} initializer * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR. From-SVN: r245592 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl.c | 3 +++ gcc/testsuite/g++.dg/template/init11.C | 9 +++++++++ 3 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/init11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ff836e28d0..3ae889317f4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-02-19 Jason Merrill + PR c++/79607 - ICE with T{} initializer + * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR. + PR c++/79566 - elaborated-type-specifier in range for * parser.c (cp_parser_simple_declaration): Fix check for type definition. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 70c44fbb9f0..e5c2bab214b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6662,6 +6662,9 @@ type_dependent_init_p (tree init) else if (TREE_CODE (init) == CONSTRUCTOR) /* A brace-enclosed initializer, e.g.: int i = { 3 }; ? */ { + if (dependent_type_p (TREE_TYPE (init))) + return true; + vec *elts; size_t nelts; size_t i; diff --git a/gcc/testsuite/g++.dg/template/init11.C b/gcc/testsuite/g++.dg/template/init11.C new file mode 100644 index 00000000000..ef337c0be60 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/init11.C @@ -0,0 +1,9 @@ +// PR c++/79607 +// { dg-do compile { target c++11 } } + +template struct A +{ + static const int i = int{T{}}; +}; + +A a; -- 2.30.2