diff options
author | pfg <pfg@FreeBSD.org> | 2016-06-10 22:07:17 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-06-10 22:07:17 +0000 |
commit | 3ded2f82545e5c17bf235b22ce577b37ded4addd (patch) | |
tree | 493064f2fcbf2e0c2bdf3634e37237f76ac87cbb /contrib/gcc | |
parent | c430f449a0c53d34e550131700a604cc50f3292b (diff) | |
download | FreeBSD-src-3ded2f82545e5c17bf235b22ce577b37ded4addd.zip FreeBSD-src-3ded2f82545e5c17bf235b22ce577b37ded4addd.tar.gz |
MFC r300301, r300319:
GCC: Add support for named initializers for anonymous structs/unions.
This is a C11 feature that is starting to get used in places such as Mesa.
This implementation takes a different approach to upstream and is
therefore not covered by GPLv3.
Obtained from: OpenBSD (CVS rev. 1.2)
Diffstat (limited to 'contrib/gcc')
-rw-r--r-- | contrib/gcc/c-typeck.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/contrib/gcc/c-typeck.c b/contrib/gcc/c-typeck.c index 0101176..670c0ad 100644 --- a/contrib/gcc/c-typeck.c +++ b/contrib/gcc/c-typeck.c @@ -6041,6 +6041,7 @@ set_init_index (tree first, tree last) void set_init_label (tree fieldname) { + tree anon = NULL_TREE; tree tail; if (set_designator (0)) @@ -6058,19 +6059,39 @@ set_init_label (tree fieldname) for (tail = TYPE_FIELDS (constructor_type); tail; tail = TREE_CHAIN (tail)) { + if (DECL_NAME (tail) == NULL_TREE + && (TREE_CODE (TREE_TYPE (tail)) == RECORD_TYPE + || TREE_CODE (TREE_TYPE (tail)) == UNION_TYPE)) + { + anon = lookup_field (tail, fieldname); + if (anon) + break; + } + if (DECL_NAME (tail) == fieldname) break; } 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; } } |