From befd067c5ab038183979ee93a7010b5dcc9f1e2e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 11 Dec 2012 13:16:39 -0500 Subject: [PATCH] * pt.c (maybe_process_partial_specialization): Handle aliases first. From-SVN: r194407 --- gcc/cp/ChangeLog | 4 +++ gcc/cp/pt.c | 30 ++++++++++------------- gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index baa119dbca9..02c0bfe20b2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2012-12-11 Jason Merrill + + * pt.c (maybe_process_partial_specialization): Handle aliases first. + 2012-12-11 Jakub Jelinek PR c++/55619 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1bc9e1bef14..f30a1e170eb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -812,13 +812,17 @@ maybe_process_partial_specialization (tree type) context = TYPE_CONTEXT (type); - if ((CLASS_TYPE_P (type) && CLASSTYPE_USE_TEMPLATE (type)) - /* Consider non-class instantiations of alias templates as - well. */ - || (TYPE_P (type) - && TYPE_TEMPLATE_INFO (type) - && DECL_LANG_SPECIFIC (TYPE_NAME (type)) - && DECL_USE_TEMPLATE (TYPE_NAME (type)))) + if (TYPE_ALIAS_P (type)) + { + if (TYPE_TEMPLATE_INFO (type) + && DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (type))) + error ("specialization of alias template %qD", + TYPE_TI_TEMPLATE (type)); + else + error ("explicit specialization of non-template %qT", type); + return error_mark_node; + } + else if (CLASS_TYPE_P (type) && CLASSTYPE_USE_TEMPLATE (type)) { /* This is for ordinary explicit specialization and partial specialization of a template class such as: @@ -831,8 +835,7 @@ maybe_process_partial_specialization (tree type) Make sure that `C' and `C' are implicit instantiations. */ - if (CLASS_TYPE_P (type) - && CLASSTYPE_IMPLICIT_INSTANTIATION (type) + if (CLASSTYPE_IMPLICIT_INSTANTIATION (type) && !COMPLETE_TYPE_P (type)) { check_specialization_namespace (CLASSTYPE_TI_TEMPLATE (type)); @@ -845,16 +848,9 @@ maybe_process_partial_specialization (tree type) return error_mark_node; } } - else if (CLASS_TYPE_P (type) - && CLASSTYPE_TEMPLATE_INSTANTIATION (type)) + else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type)) error ("specialization of %qT after instantiation", type); - if (DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (type))) - { - error ("partial specialization of alias template %qD", - TYPE_TI_TEMPLATE (type)); - return error_mark_node; - } } else if (CLASS_TYPE_P (type) && !CLASSTYPE_USE_TEMPLATE (type) diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C index d0eda5ff1b9..cbba90fa133 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C @@ -5,10 +5,10 @@ template struct A0 {}; template using AA0 = A0; -template struct AA0 {}; // { dg-error "partial specialization" } +template struct AA0 {}; // { dg-error "specialization" } template using Ptr = U*; -template struct Ptr {}; // { dg-error "partial specialization" } +template struct Ptr {}; // { dg-error "specialization" } struct A { using A = int;//{ dg-error "nested|has|same name as|class|in which|declared" } -- 2.30.2