commit 95fed08c94d20b03994248b5ffa3e5d41a4aff7d
Author: Jason Merrill <jason@redhat.com>
Date: Tue Mar 19 10:11:18 2013 -0400
* name-lookup.c (get_anonymous_namespace_name): Never use
get_file_function_name.
@@ -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;
}
new file mode 100644
@@ -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 (...) { }
+}
new file mode 100644
@@ -0,0 +1,10 @@
+namespace {
+ struct A
+ {
+ virtual void f();
+ };
+
+ void A::f() { }
+}
+
+void g() { throw A(); }
new file mode 100644
@@ -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 (...) { }
+}