aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-03-18 14:36:19 -0400
committerJason Merrill <jason@redhat.com>2022-03-21 16:46:31 -0400
commite3e191b4104c7d6a177f66dbb77cabf05ab63781 (patch)
treee68af1e50db30c91671c5585ac5e8d59f09b2904 /gcc/cp/decl.cc
parent3873e614ef295b9fc8b3a1fc536d29d0c3fe37c0 (diff)
downloadgcc-e3e191b4104c7d6a177f66dbb77cabf05ab63781.zip
gcc-e3e191b4104c7d6a177f66dbb77cabf05ab63781.tar.gz
gcc-e3e191b4104c7d6a177f66dbb77cabf05ab63781.tar.bz2
c++: designator and anon struct [PR101767]
We found .x in the anonymous struct, but then didn't find .y there; we should decide that means we're done with the struct rather than that the code is wrong. PR c++/101767 gcc/cp/ChangeLog: * decl.cc (reshape_init_class): Back out of anon struct if a designator doesn't match. gcc/testsuite/ChangeLog: * g++.dg/ext/anon-struct10.C: New test.
Diffstat (limited to 'gcc/cp/decl.cc')
-rw-r--r--gcc/cp/decl.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 8afda826..375385e 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -6626,6 +6626,11 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
return error_mark_node;
}
+ if (!field && ANON_AGGR_TYPE_P (type))
+ /* Apparently the designator isn't for a member of this anonymous
+ struct, so head back to the enclosing class. */
+ break;
+
if (!field || TREE_CODE (field) != FIELD_DECL)
{
if (complain & tf_error)