Commit 07782718 by Kriang Lerdsuwanakij Committed by Kriang Lerdsuwanakij

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: r53621
parent 47754fd5
2002-05-19 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/186, DR 259
* pt.c (do_decl_instantiation): Don't complain explicit
instantiation after explicit specialization.
(do_type_instantiation): Likewise.
2002-05-19 Alexandre Oliva <aoliva@redhat.com> 2002-05-19 Alexandre Oliva <aoliva@redhat.com>
* cp-tree.h (complete_type_or_diagnostic): Changed prototype, * cp-tree.h (complete_type_or_diagnostic): Changed prototype,
......
...@@ -9524,12 +9524,16 @@ do_decl_instantiation (declspecs, declarator, storage) ...@@ -9524,12 +9524,16 @@ do_decl_instantiation (declspecs, declarator, storage)
if (DECL_TEMPLATE_SPECIALIZATION (result)) 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 For a given set of template parameters, if an explicit
specialize a template. */ instantiation of a template appears after a declaration of an
pedwarn ("explicit instantiation of `%#D' after", result); explicit specialization for that template, the explicit
cp_pedwarn_at ("explicit specialization here", result); instantiation has no effect. */
return; return;
} }
else if (DECL_EXPLICIT_INSTANTIATION (result)) else if (DECL_EXPLICIT_INSTANTIATION (result))
...@@ -9659,15 +9663,16 @@ do_type_instantiation (t, storage, complain) ...@@ -9659,15 +9663,16 @@ do_type_instantiation (t, storage, complain)
if (CLASSTYPE_TEMPLATE_SPECIALIZATION (t)) if (CLASSTYPE_TEMPLATE_SPECIALIZATION (t))
{ {
/* [temp.spec] /* DR 259 [temp.spec].
No program shall both explicitly instantiate and explicitly Both an explicit instantiation and a declaration of an explicit
specialize a template. */ specialization shall not appear in a program unless the explicit
if (complain & tf_error) instantiation follows a declaration of the explicit specialization.
{
error ("explicit instantiation of `%#T' after", t); For a given set of template parameters, if an explicit
cp_error_at ("explicit specialization here", t); instantiation of a template appears after a declaration of an
} explicit specialization for that template, the explicit
instantiation has no effect. */
return; return;
} }
else if (CLASSTYPE_EXPLICIT_INSTANTIATION (t)) else if (CLASSTYPE_EXPLICIT_INSTANTIATION (t))
......
...@@ -28,14 +28,14 @@ template class S<void*>; // OK - explicit instantiation of partial ...@@ -28,14 +28,14 @@ template class S<void*>; // OK - explicit instantiation of partial
// specialization // specialization
template <> template <>
struct S<long double> {}; // ERROR - explicit specialization struct S<long double> {};
template class S<long double>; // ERROR - explicit instantiation after template class S<long double>; // OK - explicit instantiation after
template <> 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 <class T> template <class T>
void g(T); void g(T);
......
// Build don't link: // Build don't link:
template<class T> T f(T o) { return o; } template<class T> T f(T o) { return o; }
template<> int f(int o) { return o; } // ERROR - after specialization template<> int f(int o) { return o; }
template int f(int); // ERROR - explicit instantiation template int f(int);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment