diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-17 22:02:09 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-17 22:02:09 +0000 |
commit | 61385e344f51b4439d67095f02b19e4d271d805b (patch) | |
tree | 4d70f2e6000447d2f08e910d9fb5dea2f5bd0f1c /gcc | |
parent | 57b56075469495e8c90d2a78998777b2abfb768a (diff) | |
download | gcc-61385e344f51b4439d67095f02b19e4d271d805b.tar.gz |
PR c++/22139
* cp-tree.h (DECL_TEMPLATE_INFO): Improve documentation.
* decl.c (duplicate_decls): Re-register template specializations
for functions that have DECL_TEMLPLATE_INFO, even if they do not
have DECL_TEMPLATE_INSTANTIATION set.
PR c++/22139
* g++.dg/template/friend36.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102118 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 20 | ||||
-rw-r--r-- | gcc/cp/decl.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/friend36.C | 10 |
5 files changed, 42 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6ebdca92a8e..4c048cf4bd8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2005-07-17 Mark Mitchell <mark@codesourcery.com> + + PR c++/22139 + * cp-tree.h (DECL_TEMPLATE_INFO): Improve documentation. + * decl.c (duplicate_decls): Re-register template specializations + for functions that have DECL_TEMLPLATE_INFO, even if they do not + have DECL_TEMPLATE_INSTANTIATION set. + 2005-07-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * call.c (diagnostic_fn_t): New. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 440bdff1c6b..2d5e5f1f41d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2056,8 +2056,24 @@ extern void decl_shadowed_for_var_insert (tree, tree); #define DECL_DEFERRED_FN(DECL) \ (DECL_LANG_SPECIFIC (DECL)->decl_flags.deferred) -/* For a VAR_DECL, FUNCTION_DECL, TYPE_DECL or TEMPLATE_DECL: - template-specific information. */ +/* If non-NULL for a VAR_DECL, FUNCTION_DECL, TYPE_DECL or + TEMPLATE_DECL, the entity is a template specialization. In that + case, DECL_TEMPLATE_INFO is a TREE_LIST, whose TREE_PURPOSE is the + TEMPLATE_DECL of which this entity is a specialization. The TREE_ + TREE_VALUE is the template arguments used to specialize the + template. + + In general, DECL_TEMPLATE_INFO is non-NULL only if + DECL_USE_TEMPLATE is non-zero. However, for friends, we sometimes + have DECL_TEMPLATE_INFO even when DECL_USE_TEMPLATE is zero. + Consider: + + template <typename T> struct S { friend void f(T) {} }; + + In this case, S<int>::f is, from the point of view of the compiler, + an instantiation of a template -- but, from the point of view of + the language, each instantiation of S results in a wholly unrelated + global function f. */ #define DECL_TEMPLATE_INFO(NODE) \ (DECL_LANG_SPECIFIC (VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK (NODE)) \ ->decl_flags.u.template_info) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ee6a89b71f6..855906a0188 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1838,7 +1838,7 @@ duplicate_decls (tree newdecl, tree olddecl) memcpy ((char *) olddecl + sizeof (struct tree_decl_common), (char *) newdecl + sizeof (struct tree_decl_common), sizeof (struct tree_function_decl) - sizeof (struct tree_decl_common)); - if (DECL_TEMPLATE_INSTANTIATION (newdecl)) + if (DECL_TEMPLATE_INFO (newdecl)) /* If newdecl is a template instantiation, it is possible that the following sequence of events has occurred: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index db07da58a77..2f186052745 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-07-17 Mark Mitchell <mark@codesourcery.com> + + PR c++/22139 + * g++.dg/template/friend36.C: New test. + 2005-07-16 David Edelsohn <edelsohn@gnu.org> PR fortran/21730 diff --git a/gcc/testsuite/g++.dg/template/friend36.C b/gcc/testsuite/g++.dg/template/friend36.C new file mode 100644 index 00000000000..5f07db486c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend36.C @@ -0,0 +1,10 @@ +// PR c++/22139 +// { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } + +template <int rank, int dim> class Tensor; +template <int rank, int dim> struct SymmetricTensor { + SymmetricTensor (const Tensor<2,dim> &t); + friend void foo(); +}; +template <> SymmetricTensor<2,2>::SymmetricTensor (const Tensor<2,2> &t) {} +template <> SymmetricTensor<2,3>::SymmetricTensor (const Tensor<2,3> &t) {} |