@@ -755,6 +755,23 @@ end_explicit_instantiation (void)
processing_explicit_instantiation = false;
}
+/* SPEC is an explicit instantiation. Check that it is valid to
+ perform this explicit instantiation in the current namespace. */
+
+static void
+check_explicit_instantiation_namespace (tree spec)
+{
+ tree ns;
+
+ /* DR 275: An explicit instantiation shall appear in an enclosing
+ namespace of its template. */
+ ns = decl_namespace_context (spec);
+ if (!is_ancestor (current_namespace, ns))
+ permerror (input_location, "explicit instantiation of %qD in namespace %qD "
+ "(which does not enclose namespace %qD)",
+ spec, current_namespace, ns);
+}
+
/* An explicit specialization or partial specialization of TMPL is being
declared. Check that the namespace in which the specialization is
occurring is permissible. Returns false iff it is invalid to
@@ -785,29 +802,19 @@ check_specialization_namespace (tree tmpl)
return true;
else
{
- permerror (input_location, "specialization of %qD in different namespace", tmpl);
- permerror (input_location, " from definition of %q+#D", tmpl);
+ if (cxx_dialect < cxx11)
+ {
+ permerror (input_location, "specialization of %qD in different "
+ "namespace", tmpl);
+ permerror (input_location, " from definition of %q+#D", tmpl);
+ }
+ else
+ check_explicit_instantiation_namespace (tmpl);
+
return false;
}
}
-/* SPEC is an explicit instantiation. Check that it is valid to
- perform this explicit instantiation in the current namespace. */
-
-static void
-check_explicit_instantiation_namespace (tree spec)
-{
- tree ns;
-
- /* DR 275: An explicit instantiation shall appear in an enclosing
- namespace of its template. */
- ns = decl_namespace_context (spec);
- if (!is_ancestor (current_namespace, ns))
- permerror (input_location, "explicit instantiation of %qD in namespace %qD "
- "(which does not enclose namespace %qD)",
- spec, current_namespace, ns);
-}
-
/* The TYPE is being declared. If it is a template type, that means it
is a partial specialization. Do appropriate error-checking. */
@@ -1,11 +1,11 @@
// PR c++/16224
namespace io {
- template <typename> int foo(); // { dg-error "" }
+ template <typename> int foo(); // { dg-error "" "" { target { ! c++11 } } }
}
using namespace io;
-template<> int foo<int>(); // { dg-error "" }
+template<> int foo<int>(); // { dg-error "" "" { target { ! c++11 } } }
int a = foo<int>();
@@ -1,10 +1,10 @@
namespace N {
template <typename T>
struct S {
- void f() {} // { dg-error "definition" }
+ void f() {} // { dg-error "definition" "" { target { ! c++11 } } }
};
}
namespace K {
- template <> void N::S<char>::f() {} // { dg-error "different namespace" }
+ template <> void N::S<char>::f() {} // { dg-error "namespace" }
}
@@ -8,9 +8,9 @@ struct basic_string
namespace MyNS {
class MyClass {
template <typename T>
- T test() { } /* { dg-error "from definition" } */
+ T test() { } /* { dg-error "from definition" "" { target { ! c++11 } } } */
};
}
template <>
-basic_string MyNS::MyClass::test() /* { dg-error "specialization of" } */
+basic_string MyNS::MyClass::test() /* { dg-error "specialization of" "" { target { ! c++11 } } } */
{ return 1; }
@@ -4,18 +4,18 @@ namespace bar
{
// trick it to provide some prior declaration
template<class T>
- void foo(); // { dg-error "definition" }
+ void foo(); // { dg-error "definition" "" { target { ! c++11 } } }
template<class T>class X; // { dg-message "note: previous declaration" }
}
template <typename T>
T const
-bar::foo(T const &a) // { dg-error "" "" { xfail *-*-* } } not declared in bar -
+bar::foo(T const &a) // { dg-error "" "" { xfail *-*-* } } not declared in bar -
{
return a;
}
-template<> void bar::foo<int>() // { dg-error "different namespace" }
+template<> void bar::foo<int>() // { dg-error "different namespace" "" { target { ! c++11 } } }
{
}
@@ -7,9 +7,9 @@
// the template
namespace N {
- template <class T> class foo; // { dg-error "" } referenced below
+ template <class T> class foo; // { dg-error "" "" { target { ! c++11 } } } referenced below
}
using namespace N;
-template <> class foo<void>; // { dg-error "" } invalid specialization
+template <> class foo<void>; // { dg-error "" "" { target { ! c++11 } } } invalid specialization
@@ -13,8 +13,8 @@ namespace Outer {
namespace Core = Core_Real;
namespace Core_Real {
- template<class T> void Foo (T *) {} // { dg-error "definition" }
+ template<class T> void Foo (T *) {} // { dg-error "definition" "" { target { ! c++11 } } }
}
- template<> void Core::Foo<> (Render_Real::Type *) {} // { dg-error "" }
+ template<> void Core::Foo<> (Render_Real::Type *) {} // { dg-error "" "" { target { ! c++11 } } }
}