aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-03-30 16:08:51 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-03-30 16:08:51 -0400
commit6d92f13104acabd09f3a2bc6ad41f75bded22771 (patch)
tree8f18d0dfdaf2760011bb9f0b62e318dfd355f220 /gcc
parent9d620422f5ba32ae0dc1daf47da5382f876408f5 (diff)
downloadgcc-6d92f13104acabd09f3a2bc6ad41f75bded22771.zip
gcc-6d92f13104acabd09f3a2bc6ad41f75bded22771.tar.gz
gcc-6d92f13104acabd09f3a2bc6ad41f75bded22771.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck2.c3
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/desig9.C13
3 files changed, 21 insertions, 1 deletions
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 <jason@redhat.com>
+
+ * 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 <jakub@redhat.com>
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,
+};