]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/52915 ([C++11] Deleted default-constructor of anonymous unions not honored)
authorJason Merrill <jason@redhat.com>
Fri, 13 Apr 2012 19:43:37 +0000 (15:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Apr 2012 19:43:37 +0000 (15:43 -0400)
PR c++/52915
* decl2.c (finish_anon_union): Use cp_finish_decl.
* error.c (dump_function_name): Avoid showing anonymous "name".

From-SVN: r186432

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/anon-union2.C [new file with mode: 0644]

index c822ca240a3927ab70b57dcf6d0d772d38caaf58..4bb79371109e3cc416be18a757732895d9829d54 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52915
+       * decl2.c (finish_anon_union): Use cp_finish_decl.
+       * error.c (dump_function_name): Avoid showing anonymous "name".
+
 2012-04-11  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
        PR c++/52465
index b048ac7b3cd569c1478526f7a565360e9bb4ce0d..212feeae313811b56028b10e7fc998f3edfd20e3 100644 (file)
@@ -1456,12 +1456,7 @@ finish_anon_union (tree anon_union_decl)
     }
 
   pushdecl (anon_union_decl);
-  if (building_stmt_list_p ()
-      && at_function_scope_p ())
-    add_decl_expr (anon_union_decl);
-  else if (!processing_template_decl)
-    rest_of_decl_compilation (anon_union_decl,
-                             toplevel_bindings_p (), at_eof);
+  cp_finish_decl (anon_union_decl, NULL_TREE, false, NULL_TREE, 0);
 }
 \f
 /* Auxiliary functions to make type signatures for
index ee8f0e082a5d54273dc40952828b3270c9887e0b..77eb306823c57831948ffd52ede59bb6a9d20103 100644 (file)
@@ -1556,6 +1556,8 @@ dump_function_name (tree t, int flags)
     {
       if (LAMBDA_TYPE_P (DECL_CONTEXT (t)))
        name = get_identifier ("<lambda>");
+      else if (TYPE_ANONYMOUS_P (DECL_CONTEXT (t)))
+       name = get_identifier ("<constructor>");
       else
        name = constructor_name (DECL_CONTEXT (t));
     }
index 556d2f6db86878bafa88fd34b9cc3479f504a3f3..587e112626a58617ca95f4fac55f94f0d72677ce 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52915
+       * g++.dg/other/anon-union2.C: New.
+
 2012-04-13  Martin Jambor  <mjambor@suse.cz>
 
        PR middle-end/52939
diff --git a/gcc/testsuite/g++.dg/other/anon-union2.C b/gcc/testsuite/g++.dg/other/anon-union2.C
new file mode 100644 (file)
index 0000000..31bb74f
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/52915
+
+struct S {
+  int val;
+  S(int v) : val(v) {}
+};
+
+void f() {
+  union { S a; };              // { dg-error "constructor|no match" }
+}