From: Paolo Carlini Date: Thu, 14 Feb 2008 12:34:42 +0000 (+0000) Subject: re PR c++/28743 (ICE with invalid specialization) X-Git-Tag: releases/gcc-4.3.0~163 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4571259b7a5875586d1579334aa9b944b103216b;p=thirdparty%2Fgcc.git re PR c++/28743 (ICE with invalid specialization) /cp 2008-02-14 Paolo Carlini 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-02-14 Paolo Carlini PR c++/28743 * g++.dg/template/nontype17.C: New. * g++.dg/template/nontype16.C: Add error. From-SVN: r132316 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c237abda40de..275ca4b1aebf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-02-14 Paolo Carlini + + 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. + 2008-02-13 Jakub Jelinek Manuel Lopez-Ibanez diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 577b62165808..2e2a636d239b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1561,12 +1561,9 @@ determine_specialization (tree template_id, 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; - } + if (tsk == tsk_template + && !compparms (fn_arg_types, decl_arg_types)) + continue; /* See whether this function might be a specialization of this template. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0eac359748fa..7a4d5bb4d871 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-02-14 Paolo Carlini + + PR c++/28743 + * g++.dg/template/nontype17.C: New. + * g++.dg/template/nontype16.C: Add error. + 2008-02-13 Jakub Jelinek PR c++/35138 diff --git a/gcc/testsuite/g++.dg/template/nontype16.C b/gcc/testsuite/g++.dg/template/nontype16.C index 36d1e9564a09..4b9f7602876c 100644 --- a/gcc/testsuite/g++.dg/template/nontype16.C +++ b/gcc/testsuite/g++.dg/template/nontype16.C @@ -5,5 +5,5 @@ template struct A template void foo(); }; -template<> template void A<0>::foo() {} // { dg-error "not a valid type" } +template<> template void A<0>::foo() {} // { dg-error "not a valid type|match" } diff --git a/gcc/testsuite/g++.dg/template/nontype17.C b/gcc/testsuite/g++.dg/template/nontype17.C new file mode 100644 index 000000000000..c8f3404dea77 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nontype17.C @@ -0,0 +1,8 @@ +// PR c++/28743 + +template struct A +{ + template void foo(); +}; + +template template void A<0>::foo() {} // { dg-error "match" }