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
This commit is contained in:
parent
f541609868
commit
2f54a1db5e
4 changed files with 56 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
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
|
||||
|
|
20
gcc/cp/pt.c
20
gcc/cp/pt.c
|
@ -1629,15 +1629,21 @@ check_explicit_specialization (tree declarator,
|
|||
{
|
||||
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);
|
||||
|
||||
declarator =
|
||||
lookup_template_function (fns, NULL_TREE);
|
||||
/* Find the namespace binding, using the declaration
|
||||
context. */
|
||||
fns = namespace_binding (dname, CP_DECL_CONTEXT (decl));
|
||||
}
|
||||
|
||||
declarator = lookup_template_function (fns, NULL_TREE);
|
||||
}
|
||||
|
||||
if (declarator == error_mark_node)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
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.
|
||||
|
|
31
gcc/testsuite/g++.dg/template/explicit-instantiation3.C
Normal file
31
gcc/testsuite/g++.dg/template/explicit-instantiation3.C
Normal file
|
@ -0,0 +1,31 @@
|
|||
// { 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>;
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue