From 012d5d2526e73eb98190fdabfd86e075ed5c7d50 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 23 Jun 2011 12:52:48 -0400 Subject: [PATCH] re PR c++/49440 (Invalid dynamic_cast for unnamed namespace) PR c++/49440 * class.c (set_linkage_according_to_type): Just check TREE_PUBLIC on the type's name. From-SVN: r175340 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/class.c | 17 +++-------------- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/rtti/anon-ns1.C | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/g++.dg/rtti/anon-ns1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a8fbf7ba179..da39680df0e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-06-23 Jason Merrill + PR c++/49440 + * class.c (set_linkage_according_to_type): Just check TREE_PUBLIC + on the type's name. + PR c++/49395 * init.c (build_zero_init_1): Strip cv-quals from scalar types. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 09444fb49ec..9e387a6923e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -677,21 +677,10 @@ get_vtable_name (tree type) the abstract. */ void -set_linkage_according_to_type (tree type, tree decl) +set_linkage_according_to_type (tree type ATTRIBUTE_UNUSED, tree decl) { - /* If TYPE involves a local class in a function with internal - linkage, then DECL should have internal linkage too. Other local - classes have no linkage -- but if their containing functions - have external linkage, it makes sense for DECL to have external - linkage too. That will allow template definitions to be merged, - for example. */ - if (no_linkage_check (type, /*relaxed_p=*/true)) - { - TREE_PUBLIC (decl) = 0; - DECL_INTERFACE_KNOWN (decl) = 1; - } - else - TREE_PUBLIC (decl) = 1; + TREE_PUBLIC (decl) = 1; + determine_visibility (decl); } /* Create a VAR_DECL for a primary or secondary vtable for CLASS_TYPE. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dda6cfffecc..ec75281ff21 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-06-23 Jason Merrill + PR c++/49440 + * g++.dg/rtti/anon-ns1.C: New. + PR c++/49395 * g++.dg/init/ref18.C: New. diff --git a/gcc/testsuite/g++.dg/rtti/anon-ns1.C b/gcc/testsuite/g++.dg/rtti/anon-ns1.C new file mode 100644 index 00000000000..fd6f8af61b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/anon-ns1.C @@ -0,0 +1,15 @@ +// PR c++/49440 +// The typeinfo name for A should start with * so we compare +// it by address rather than contents. + +// { dg-final { scan-assembler "\"\*N\[^\"\]+1AE\"" } } + +namespace +{ + class A { }; +} + +void f() +{ + throw A(); +} -- 2.30.2