Commit 2f54a1db by Giovanni Bajo Committed by Nathan Sidwell

re PR c++/8266 (Explicit instantiation of a template outside its namespace is broken)

From  Giovanni Bajo  <giovannibajo@libero.it>
cp:
       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.
testsuite:
        PR c++/8266
        * g++.dg/template/explicit-instantiation3.C: New test.

From-SVN: r68527
parent f5416098
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> 2003-06-25 Mark Mitchell <mark@codesourcery.com>
PR c++/10990 PR c++/10990
......
...@@ -1629,15 +1629,21 @@ check_explicit_specialization (tree declarator, ...@@ -1629,15 +1629,21 @@ check_explicit_specialization (tree declarator,
{ {
tree fns; tree fns;
my_friendly_assert (TREE_CODE (declarator) == IDENTIFIER_NODE, my_friendly_assert (TREE_CODE (declarator) == IDENTIFIER_NODE, 0);
0); if (ctype)
if (!ctype)
fns = IDENTIFIER_NAMESPACE_VALUE (dname);
else
fns = dname; 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 = declarator = lookup_template_function (fns, NULL_TREE);
lookup_template_function (fns, NULL_TREE);
} }
if (declarator == error_mark_node) 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> 2003-06-26 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/20030626-1.c: Use signed char. * gcc.dg/20030626-1.c: Use signed char.
......
// { 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>;
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