diff options
author | pfg <pfg@FreeBSD.org> | 2016-05-20 14:36:49 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-05-20 14:36:49 +0000 |
commit | 7e54d481ce2d6bfb6efcd1ce7d13e4cf512b50c5 (patch) | |
tree | 2216d7d6e7ad6e758a9076b68bde3f78492ea17b | |
parent | 8dc7f1d8c74b3019a56fa6291f6076e83417ff2b (diff) | |
download | FreeBSD-src-7e54d481ce2d6bfb6efcd1ce7d13e4cf512b50c5.zip FreeBSD-src-7e54d481ce2d6bfb6efcd1ce7d13e4cf512b50c5.tar.gz |
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)
MFC after: 3 weeks
-rw-r--r-- | contrib/gcc/c-typeck.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/gcc/c-typeck.c b/contrib/gcc/c-typeck.c index 0101176..0e2e907 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,6 +6059,15 @@ 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; } |