summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-21 03:25:29 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-21 03:25:29 +0000
commit6ef87af265959a9cc0f510ed4b31c092d68b25a4 (patch)
tree573c20c17470b7ae5a40b32220bb10965aa2f9a9
parentc99b736ec0bcdc7d26ae53ae2f3ed2d8896ad06a (diff)
downloadgcc-6ef87af265959a9cc0f510ed4b31c092d68b25a4.tar.gz
* name-lookup.c (get_anonymous_namespace_name): Never use
get_file_function_name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196851 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/name-lookup.c14
-rw-r--r--gcc/testsuite/g++.dg/eh/anon1.C26
-rw-r--r--gcc/testsuite/g++.dg/eh/anon1a.cc10
-rw-r--r--gcc/testsuite/g++.dg/eh/anon2.C24
5 files changed, 69 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bef6faeb654..719f70c693a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2013-03-20 Jason Merrill <jason@redhat.com>
+ * 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 2a47331ea73..7084a535ce1 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 00000000000..2a5ef4bc5e3
--- /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 00000000000..ba161ac2b01
--- /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 00000000000..9ff9ee3ab7f
--- /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 (...) { }
+}