+2003-06-26 Giovanni Bajo <giovannibajo@libero.it>
+
+ PR c++/8266
+ * pt.c (check_explicit_specialization): When looking up a
+ template function from an identifier outside class-scope, bind
+ it to CP_DECL_CONTEXT.
+
2003-06-25 Mark Mitchell <mark@codesourcery.com>
PR c++/10990
{
tree fns;
- my_friendly_assert (TREE_CODE (declarator) == IDENTIFIER_NODE,
- 0);
- if (!ctype)
- fns = IDENTIFIER_NAMESPACE_VALUE (dname);
- else
+ my_friendly_assert (TREE_CODE (declarator) == IDENTIFIER_NODE, 0);
+ if (ctype)
fns = dname;
+ else
+ {
+ /* If there is no class context, the explicit instantiation
+ must be at namespace scope. */
+ my_friendly_assert (DECL_NAMESPACE_SCOPE_P (decl), 20030625);
+
+ /* Find the namespace binding, using the declaration
+ context. */
+ fns = namespace_binding (dname, CP_DECL_CONTEXT (decl));
+ }
- declarator =
- lookup_template_function (fns, NULL_TREE);
+ declarator = lookup_template_function (fns, NULL_TREE);
}
if (declarator == error_mark_node)
+2003-06-26 Giovanni Bajo <giovannibajo@libero.it>
+
+ PR c++/8266
+ * g++.dg/template/explicit-instantiation3.C: New test.
+
2003-06-26 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/20030626-1.c: Use signed char.
--- /dev/null
+// { dg-do compile }
+// Origin: <sebor at roguewave dot com>
+// c++/8266: Explicit instantiation of a template outside its namespace is
+// broken
+
+namespace N
+{
+ template <class T> T foo (T)
+ { return T (); }
+
+ struct A
+ {
+ template <int N>
+ struct B {};
+ };
+
+ template <int M>
+ struct C {};
+
+ template double foo(double);
+ template float foo<float>(float);
+ template struct A::B<0>;
+ template struct C<0>;
+}
+
+template int N::foo(int);
+template char N::foo<char>(char);
+template struct N::A::B<1>;
+template struct N::C<1>;
+
+