aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/testsuite/g++.dg/lookup/pr84962.C2
-rw-r--r--gcc/testsuite/g++.dg/other/anon-union5.C9
3 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 3294b4f..ec05ee1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5005,6 +5005,14 @@ fixup_anonymous_aggr (tree t)
else
prev_p = &DECL_CHAIN (probe);
+ /* Splice all functions out of CLASSTYPE_MEMBER_VEC. */
+ vec<tree,va_gc>* vec = CLASSTYPE_MEMBER_VEC (t);
+ unsigned store = 0;
+ for (tree elt : vec)
+ if (!is_overloaded_fn (elt))
+ (*vec)[store++] = elt;
+ vec_safe_truncate (vec, store);
+
/* Anonymous aggregates cannot have fields with ctors, dtors or complex
assignment operators (because they cannot have these methods themselves).
For anonymous unions this is already checked because they are not allowed
diff --git a/gcc/testsuite/g++.dg/lookup/pr84962.C b/gcc/testsuite/g++.dg/lookup/pr84962.C
index b9b7a31..c22b95c 100644
--- a/gcc/testsuite/g++.dg/lookup/pr84962.C
+++ b/gcc/testsuite/g++.dg/lookup/pr84962.C
@@ -9,6 +9,6 @@ struct X {
// { dg-error "public non-static data member" "" { target *-*-* } .-1 }
};
- int : a; // { dg-error "non-integral" }
+ int : a; // { dg-error "" }
};
diff --git a/gcc/testsuite/g++.dg/other/anon-union5.C b/gcc/testsuite/g++.dg/other/anon-union5.C
new file mode 100644
index 0000000..616dea8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon-union5.C
@@ -0,0 +1,9 @@
+// PR c++/97974
+
+struct A {
+ union {
+ operator int (); // { dg-error "anonymous union" }
+ int a;
+ };
+ operator int; // { dg-error "" }
+};