From 28fdf3f75969c74ff029dc060ab3a64f902221fd Mon Sep 17 00:00:00 2001 From: lerdsuwa Date: Sat, 13 Oct 2001 13:11:09 +0000 Subject: [PATCH] * pt.c (determine_specialization): Ignore functions without DECL_TEMPLATE_INFO. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46243 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 6 ++++++ gcc/testsuite/g++.dg/template/spec1.C | 21 +++++++++++++++++++++ gcc/testsuite/g++.dg/template/spec2.C | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/spec1.C create mode 100644 gcc/testsuite/g++.dg/template/spec2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 50af839..58e1f98 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-10-12 Kriang Lerdsuwanakij + + * pt.c (determine_specialization): Ignore functions without + DECL_TEMPLATE_INFO. + 2001-10-12 Nathan Sidwell PR g++/4476 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e29a738..229bccc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1040,6 +1040,12 @@ determine_specialization (template_id, decl, targs_out, Here, S::f is a non-template, but S is a template class. If FN has the same type as DECL, we might be in business. */ + + if (!DECL_TEMPLATE_INFO (fn)) + /* Its enclosing class is an explicit specialization + of a template class. This is not a candidate. */ + continue; + if (!same_type_p (TREE_TYPE (TREE_TYPE (decl)), TREE_TYPE (TREE_TYPE (fn)))) /* The return types differ. */ diff --git a/gcc/testsuite/g++.dg/template/spec1.C b/gcc/testsuite/g++.dg/template/spec1.C new file mode 100644 index 0000000..2799637 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec1.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +// Origin: + +// Bug: ICE during invalid instantiation of member function +// which enclosing class is specialized. + +template +struct A +{ + void f(T) {} +}; + +template<> +struct A +{ + void f(int) {} +}; + +template +void A::f(int); // { dg-error "not match" } diff --git a/gcc/testsuite/g++.dg/template/spec2.C b/gcc/testsuite/g++.dg/template/spec2.C new file mode 100644 index 0000000..de0fe4c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec2.C @@ -0,0 +1,22 @@ +// { dg-do compile } + +// Origin: + +// Bug: Overloading of ordinary and template member function +// which enclosing class is specialized is not handled correctly. + +template +struct A +{ + void f(T) {} +}; + +template<> +struct A +{ + void f(int) {} + template void f(T) {} +}; + +template +void A::f(int); -- 2.7.4