From 0d1bd3bc6027203dbc48f91adc298eeaf2cb03a1 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Fri, 20 May 2016 18:01:53 +0000 Subject: [PATCH] GCC: Add support for named initializers for anonymous structs/unions. Missing hunk from r300301. Reported by: Ed Schouten Obtained from: OpenBSD (CVS rev. 1.2) --- contrib/gcc/c-typeck.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/gcc/c-typeck.c b/contrib/gcc/c-typeck.c index 0e2e907e92d8..670c0ad592d8 100644 --- a/contrib/gcc/c-typeck.c +++ b/contrib/gcc/c-typeck.c @@ -6074,13 +6074,24 @@ set_init_label (tree fieldname) if (tail == 0) error ("unknown field %qE specified in initializer", fieldname); - else + + while (tail) { constructor_fields = tail; designator_depth++; designator_erroneous = 0; if (constructor_range_stack) push_range_stack (NULL_TREE); + + if (anon) + { + if (set_designator (0)) + return; + tail = TREE_VALUE(anon); + anon = TREE_CHAIN(anon); + } + else + tail = NULL_TREE; } }