This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ Patch] PR 28743
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 24 Jan 2008 22:52:01 +0100
- Subject: [C++ Patch] PR 28743
Hi,
I'm trying to fix this PR, also basing on Janis' regression hunt. The
below simple change seems correct and safe to me - strictly implements
the comment right above the code - but maybe we can do something smarter
and safely avoid calling get_bindings in this case. Tested x86_64-linux.
Thanks,
Paolo.
//////////////////
/cp
2008-01-24 Paolo Carlini <pcarlini@suse.de>
PR c++/28743
* pt.c (determine_specialization): In case of function templates,
when the type of DECL does not match FN there is no match.
/testsuite
2008-01-24 Paolo Carlini <pcarlini@suse.de>
PR c++/28743
* g++.dg/template/nontype17.C: New.
* g++.dg/template/nontype16.C: Add error.
Index: testsuite/g++.dg/template/nontype16.C
===================================================================
*** testsuite/g++.dg/template/nontype16.C (revision 131803)
--- testsuite/g++.dg/template/nontype16.C (working copy)
*************** template<int> struct A
*** 5,9 ****
template<typename> void foo();
};
! template<> template<struct T> void A<0>::foo() {} // { dg-error "not a valid type" }
--- 5,9 ----
template<typename> void foo();
};
! template<> template<struct T> void A<0>::foo() {} // { dg-error "not a valid type|match" }
Index: testsuite/g++.dg/template/nontype17.C
===================================================================
*** testsuite/g++.dg/template/nontype17.C (revision 0)
--- testsuite/g++.dg/template/nontype17.C (revision 0)
***************
*** 0 ****
--- 1,8 ----
+ // PR c++/28743
+
+ template<int> struct A
+ {
+ template<typename> void foo();
+ };
+
+ template<int> template<typename> void A<0>::foo() {} // { dg-error "match" }
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 131804)
--- cp/pt.c (working copy)
*************** determine_specialization (tree template_
*** 1561,1572 ****
no partial specializations of functions. Therefore, if
the type of DECL does not match FN, there is no
match. */
! if (tsk == tsk_template)
! {
! if (compparms (fn_arg_types, decl_arg_types))
! candidates = tree_cons (NULL_TREE, fn, candidates);
! continue;
! }
/* See whether this function might be a specialization of this
template. */
--- 1561,1569 ----
no partial specializations of functions. Therefore, if
the type of DECL does not match FN, there is no
match. */
! if (tsk == tsk_template
! && !compparms (fn_arg_types, decl_arg_types))
! continue;
/* See whether this function might be a specialization of this
template. */