From 7b7a44c90fda3472044ee82841be98581fc38f42 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 13 Apr 2012 19:43:37 +0000 Subject: [PATCH] PR c++/52915 * decl2.c (finish_anon_union): Use cp_finish_decl. * error.c (dump_function_name): Avoid showing anonymous "name". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186432 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl2.c | 7 +------ gcc/cp/error.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/anon-union2.C | 10 ++++++++++ 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/anon-union2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c822ca2..4bb7937 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-04-13 Jason Merrill + + 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 PR c++/52465 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index b048ac7..212feea 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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); } /* Auxiliary functions to make type signatures for diff --git a/gcc/cp/error.c b/gcc/cp/error.c index ee8f0e0..77eb306 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1556,6 +1556,8 @@ dump_function_name (tree t, int flags) { if (LAMBDA_TYPE_P (DECL_CONTEXT (t))) name = get_identifier (""); + else if (TYPE_ANONYMOUS_P (DECL_CONTEXT (t))) + name = get_identifier (""); else name = constructor_name (DECL_CONTEXT (t)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 556d2f6..587e112 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-13 Jason Merrill + + PR c++/52915 + * g++.dg/other/anon-union2.C: New. + 2012-04-13 Martin Jambor 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 index 0000000..31bb74f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon-union2.C @@ -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" } +} -- 2.7.4