From: Kriang Lerdsuwanakij Date: Sun, 19 May 2002 10:19:05 +0000 (+0000) Subject: PR c++/186, DR 259 X-Git-Tag: releases/gcc-3.1.1~321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90840cc8a5dd3e820989af540458b349598dc922;p=thirdparty%2Fgcc.git PR c++/186, DR 259 PR c++/186, DR 259 * pt.c (do_decl_instantiation): Don't complain explicit instantiation after explicit specialization. (do_type_instantiation): Likewise. From-SVN: r53622 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c04c30a3a8b2..c2f10520929c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2002-05-19 Kriang Lerdsuwanakij + + PR c++/186, DR 259 + * pt.c (do_decl_instantiation): Don't complain explicit + instantiation after explicit specialization. + (do_type_instantiation): Likewise. + 2002-05-09 Jason Merrill * pt.c (tsubst_expr) [ASM_STMT]: Copy ASM_INPUT_P. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7b6581f8b3c5..6571c70638a0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9502,12 +9502,16 @@ do_decl_instantiation (declspecs, declarator, storage) if (DECL_TEMPLATE_SPECIALIZATION (result)) { - /* [temp.spec] + /* DR 259 [temp.spec]. + + Both an explicit instantiation and a declaration of an explicit + specialization shall not appear in a program unless the explicit + instantiation follows a declaration of the explicit specialization. - No program shall both explicitly instantiate and explicitly - specialize a template. */ - pedwarn ("explicit instantiation of `%#D' after", result); - cp_pedwarn_at ("explicit specialization here", result); + For a given set of template parameters, if an explicit + instantiation of a template appears after a declaration of an + explicit specialization for that template, the explicit + instantiation has no effect. */ return; } else if (DECL_EXPLICIT_INSTANTIATION (result)) @@ -9637,15 +9641,16 @@ do_type_instantiation (t, storage, complain) if (CLASSTYPE_TEMPLATE_SPECIALIZATION (t)) { - /* [temp.spec] + /* DR 259 [temp.spec]. - No program shall both explicitly instantiate and explicitly - specialize a template. */ - if (complain & tf_error) - { - error ("explicit instantiation of `%#T' after", t); - cp_error_at ("explicit specialization here", t); - } + Both an explicit instantiation and a declaration of an explicit + specialization shall not appear in a program unless the explicit + instantiation follows a declaration of the explicit specialization. + + For a given set of template parameters, if an explicit + instantiation of a template appears after a declaration of an + explicit specialization for that template, the explicit + instantiation has no effect. */ return; } else if (CLASSTYPE_EXPLICIT_INSTANTIATION (t)) diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C index ade83fdc4430..544faf7bdb23 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C @@ -28,14 +28,14 @@ template class S; // OK - explicit instantiation of partial // specialization template <> -struct S {}; // ERROR - explicit specialization +struct S {}; -template class S; // ERROR - explicit instantiation after +template class S; // OK - explicit instantiation after template <> -void f(long double) {} // ERROR - explicit specialization +void f(long double) {} -template void f(long double); // ERROR - explicit instantiation after +template void f(long double); // OK - explicit instantiation after template void g(T); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec19.C b/gcc/testsuite/g++.old-deja/g++.pt/spec19.C index f9b601125b4c..911c6933da4a 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/spec19.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec19.C @@ -1,5 +1,5 @@ // Build don't link: template T f(T o) { return o; } -template<> int f(int o) { return o; } // ERROR - after specialization -template int f(int); // ERROR - explicit instantiation +template<> int f(int o) { return o; } +template int f(int);