diff options
author | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-04-29 18:26:47 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-04-29 18:26:47 +0000 |
commit | 446d5e4776fad70c34500b531688b1d5b24d7065 (patch) | |
tree | d220a26e776fdccac7b4361ecdf4f9253e77b616 | |
parent | 7513525363f872174cf212137d3da4ff8fb296fc (diff) | |
download | gcc-446d5e4776fad70c34500b531688b1d5b24d7065.zip gcc-446d5e4776fad70c34500b531688b1d5b24d7065.tar.gz gcc-446d5e4776fad70c34500b531688b1d5b24d7065.tar.bz2 |
re PR c++/10515 (problem when initializing a field in a union)
PR c++/10515
* cp-tree.h (lookup_field_1): Declare it.
* search.c (lookup_field_1): Make it public.
* decl.c (reshape_init): Handle designated initializers.
From-SVN: r66236
-rw-r--r-- | gcc/cp/decl.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5c3df09..1e157f7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7551,11 +7551,24 @@ reshape_init (tree type, tree *initp) { /* Loop through the initializable fields, gathering initializers. */ - /* FIXME support non-trivial labeled initializers. */ - while (*initp && field) + while (*initp) { tree field_init; + /* Handle designated initializers, as an extension. */ + if (TREE_PURPOSE (*initp)) + { + if (pedantic) + pedwarn ("ISO C++ does not allow designated initializers"); + field = lookup_field_1 (type, TREE_PURPOSE (*initp), + /*want_type=*/false); + if (!field || TREE_CODE (field) != FIELD_DECL) + error ("`%T' has no non-static data member named `%D'", + type, TREE_PURPOSE (*initp)); + } + if (!field) + break; + field_init = reshape_init (TREE_TYPE (field), initp); TREE_CHAIN (field_init) = CONSTRUCTOR_ELTS (new_init); CONSTRUCTOR_ELTS (new_init) = field_init; |