From: Jason Merrill Date: Thu, 21 Mar 2013 03:25:29 +0000 (-0400) Subject: name-lookup.c (get_anonymous_namespace_name): Never use get_file_function_name. X-Git-Tag: upstream/12.2.0~70771 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=766053b33a997fb268791967df46c5c3f9f94a64;p=platform%2Fupstream%2Fgcc.git name-lookup.c (get_anonymous_namespace_name): Never use get_file_function_name. * name-lookup.c (get_anonymous_namespace_name): Never use get_file_function_name. From-SVN: r196851 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bef6fae..719f70c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-03-20 Jason Merrill + * name-lookup.c (get_anonymous_namespace_name): Never use + get_file_function_name. + * pt.c (retrieve_specialization): Handle null tmpl argument. PR c++/17232 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 2a47331..7084a53 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -69,14 +69,12 @@ get_anonymous_namespace_name (void) { if (!anonymous_namespace_name) { - /* The anonymous namespace has to have a unique name - if typeinfo objects are being compared by name. */ - if (! flag_weak || ! SUPPORTS_ONE_ONLY) - anonymous_namespace_name = get_file_function_name ("N"); - else - /* The demangler expects anonymous namespaces to be called - something starting with '_GLOBAL__N_'. */ - anonymous_namespace_name = get_identifier ("_GLOBAL__N_1"); + /* We used to use get_file_function_name here, but that isn't + necessary now that anonymous namespace typeinfos + are !TREE_PUBLIC, and thus compared by address. */ + /* The demangler expects anonymous namespaces to be called + something starting with '_GLOBAL__N_'. */ + anonymous_namespace_name = get_identifier ("_GLOBAL__N_1"); } return anonymous_namespace_name; } diff --git a/gcc/testsuite/g++.dg/eh/anon1.C b/gcc/testsuite/g++.dg/eh/anon1.C new file mode 100644 index 0000000..2a5ef4b --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/anon1.C @@ -0,0 +1,26 @@ +// Test that the anonymous namespace isn't mangled with random characters, +// but also doesn't get mixed up with an anonymous namespace in another +// translation unit. + +// { dg-do run } +// { dg-additional-sources "anon1a.cc" } + +namespace { + struct A + { + virtual void f(); + }; + + void A::f() { } +} + +extern void g(); + +int main() +{ + try { + try { + g(); + } catch (A) { __builtin_abort(); } + } catch (...) { } +} diff --git a/gcc/testsuite/g++.dg/eh/anon1a.cc b/gcc/testsuite/g++.dg/eh/anon1a.cc new file mode 100644 index 0000000..ba161ac --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/anon1a.cc @@ -0,0 +1,10 @@ +namespace { + struct A + { + virtual void f(); + }; + + void A::f() { } +} + +void g() { throw A(); } diff --git a/gcc/testsuite/g++.dg/eh/anon2.C b/gcc/testsuite/g++.dg/eh/anon2.C new file mode 100644 index 0000000..9ff9ee3 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/anon2.C @@ -0,0 +1,24 @@ +// Test that the anonymous namespace isn't mangled with random characters, +// but also doesn't get mixed up with an anonymous namespace in another +// translation unit. +// { dg-final { scan-assembler "\\*N12_GLOBAL__N_11AE" } } + +namespace { + struct A + { + virtual void f(); + }; + + void A::f() { } +} + +extern void g(); + +int main() +{ + try { + try { + g(); + } catch (A) { __builtin_abort(); } + } catch (...) { } +}