diff options
author | Jason Merrill <jason@redhat.com> | 2009-12-18 15:49:58 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-12-18 15:49:58 -0500 |
commit | 647763566a541d9639e714b56e10a0e141003691 (patch) | |
tree | 96941ac1992923b993469c152302d55b65fcc5f7 | |
parent | 55388afda91143f447140a0b65a8b8fcfad3951b (diff) | |
download | gcc-647763566a541d9639e714b56e10a0e141003691.zip gcc-647763566a541d9639e714b56e10a0e141003691.tar.gz gcc-647763566a541d9639e714b56e10a0e141003691.tar.bz2 |
re PR c++/28300 (In-class partial specialization of class accepted)
PR c++/28300
PR c++/42062
* pt.c (check_specialization_namespace): Complain about
specialization at non-namespace scope.
From-SVN: r155349
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/spec37.C | 6 |
4 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4109c72..3bbc3fd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2009-12-18 Jason Merrill <jason@redhat.com> + PR c++/28300 + PR c++/42062 + * pt.c (check_specialization_namespace): Complain about + specialization at non-namespace scope. + PR c++/42415 * call.c (build_new_method_call): Complain about calling the constructor directly. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 395a026..5d98cbd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -742,6 +742,12 @@ check_specialization_namespace (tree tmpl) function, member class or static data member of a class template shall be declared in the namespace of which the class template is a member. */ + if (current_scope() != DECL_CONTEXT (tmpl) + && !at_namespace_scope_p ()) + { + error ("specialization of %qD must appear at namespace scope", tmpl); + return false; + } if (is_associated_namespace (current_namespace, tpl_ns)) /* Same or super-using namespace. */ return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af4e2ac..3167b8b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2009-12-18 Jason Merrill <jason@redhat.com> + PR c++/28300 + * g++.dg/template/spec37.C: New. + PR c++/42415 * g++.dg/tc1/dr147.C: Add test. diff --git a/gcc/testsuite/g++.dg/template/spec37.C b/gcc/testsuite/g++.dg/template/spec37.C new file mode 100644 index 0000000..2c01eb0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec37.C @@ -0,0 +1,6 @@ +// PR c++/28300 + +template<typename> struct A +{ + template<typename T> struct A<T*>; // { dg-error "namespace scope" } +}; |