re PR c++/79360 (ICE with NSDMI and enum in union)

Fix PR c++/79360

gcc/cp/ChangeLog:

	PR c++/79360
	* typeck2.c (process_init_constructor_union): Consider only
	FIELD_DECLs when looking for an NSDMI.

gcc/testsuite/ChangeLog:

	PR c++/79360
	* g++.dg/cpp1y/nsdmi-union2.C: New test.

From-SVN: r245239
This commit is contained in:
Patrick Palka 2017-02-07 02:20:48 +00:00
parent 10d22398b8
commit bb7d75ffce
4 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2017-02-07 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/79360
* typeck2.c (process_init_constructor_union): Consider only
FIELD_DECLs when looking for an NSDMI.
2017-02-06 Jason Merrill <jason@redhat.com>
PR c++/71193 - incomplete types in templates

View File

@ -1510,7 +1510,8 @@ process_init_constructor_union (tree type, tree init,
{
for (tree field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
{
if (DECL_INITIAL (field))
if (TREE_CODE (field) == FIELD_DECL
&& DECL_INITIAL (field) != NULL_TREE)
{
CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (init),
field,

View File

@ -1,3 +1,8 @@
2017-02-07 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/79360
* g++.dg/cpp1y/nsdmi-union2.C: New test.
2017-02-06 Kito Cheng <kito.cheng@gmail.com>
* lib/target-supports.exp: Define the RISC-V target.

View File

@ -0,0 +1,12 @@
// PR c++/79360
// { dg-do compile { target c++14 } }
union U
{
enum E { e };
};
struct A
{
U u{};
};