From: Jason Merrill Date: Fri, 30 Mar 2018 20:08:51 +0000 (-0400) Subject: Fix designated initializer for anonymous union. X-Git-Tag: upstream/12.2.0~32594 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d92f13104acabd09f3a2bc6ad41f75bded22771;p=platform%2Fupstream%2Fgcc.git Fix designated initializer for anonymous union. * typeck2.c (process_init_constructor_record): Use init_list_type_node for the CONSTRUCTOR around an anonymous union designated initializer. From-SVN: r258982 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 13b2435..3ea9faa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-30 Jason Merrill + + * typeck2.c (process_init_constructor_record): Use + init_list_type_node for the CONSTRUCTOR around an anonymous union + designated initializer. + 2018-03-30 Jakub Jelinek PR c++/84791 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 464e8a7..3aae0a3 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1435,7 +1435,8 @@ process_init_constructor_record (tree type, tree init, int nested, designated-initializer-list { D }, where D is the designated-initializer-clause naming a member of the anonymous union object. */ - next = build_constructor_single (type, ce->index, ce->value); + next = build_constructor_single (init_list_type_node, + ce->index, ce->value); else { ce = NULL; diff --git a/gcc/testsuite/g++.dg/cpp2a/desig9.C b/gcc/testsuite/g++.dg/cpp2a/desig9.C new file mode 100644 index 0000000..990a2aa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/desig9.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "" } + +struct A { + union { + int a; + char b; + }; +}; + +struct A x = { + .a = 5, +};