From patchwork Wed Oct 24 17:20:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++] PR 34892 Date: Wed, 24 Oct 2012 07:20:42 -0000 From: Paolo Carlini X-Patchwork-Id: 193869 Message-Id: <5088236A.4060408@oracle.com> To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill Hi, a *very* old ICE on invalid, even a regression (from before variadic templates, I guess!). I tried various other tweaks, like catching the issue earlier but diagnostic quality decreases, too many cascading error messages. The below means I have to tweak only a couple of existing testcases, and I'm actually pretty happy with that, because we produce much less verbose diagnostic in both cases (1 error message less / 2 respectively). Tested x86_64-linux. Thanks, Paolo. ////////////////////////// /cp 2012-10-24 Paolo Carlini PR c++/34892 * pt.c (coerce_template_parms): Check TREE_PURPOSE (parm) for error_mark_node. /testsuite 2012-10-24 Paolo Carlini PR c++/34892 * g++.dg/template/crash114.C: New. * g++.dg/template/crash55.C: Tweak dg-error directive. * g++.dg/template/crash57.C: Likewise. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 192762) +++ cp/pt.c (working copy) @@ -6645,11 +6645,12 @@ coerce_template_parms (tree parms, /* Get the Ith template parameter. */ parm = TREE_VEC_ELT (parms, parm_idx); - if (parm == error_mark_node) - { - TREE_VEC_ELT (new_inner_args, arg_idx) = error_mark_node; - continue; - } + if (parm == error_mark_node + || TREE_PURPOSE (parm) == error_mark_node) + { + TREE_VEC_ELT (new_inner_args, arg_idx) = error_mark_node; + continue; + } /* Calculate the next argument. */ if (arg_idx < nargs) Index: testsuite/g++.dg/template/crash114.C =================================================================== --- testsuite/g++.dg/template/crash114.C (revision 0) +++ testsuite/g++.dg/template/crash114.C (working copy) @@ -0,0 +1,5 @@ +// PR c++/34892 + +template struct A {}; // { dg-error "expected" } +// { dg-message "variadic" "" { target c++98 } 3 } +A<0> a; // { dg-error "type" } Index: testsuite/g++.dg/template/crash55.C =================================================================== --- testsuite/g++.dg/template/crash55.C (revision 192762) +++ testsuite/g++.dg/template/crash55.C (working copy) @@ -3,4 +3,4 @@ template // { dg-error "nested-name-specifier|two or more|valid type" } struct A {}; -template void foo(A); // { dg-error "mismatch|constant|template argument" } +template void foo(A); // { dg-error "type|template" } Index: testsuite/g++.dg/template/crash57.C =================================================================== --- testsuite/g++.dg/template/crash57.C (revision 192762) +++ testsuite/g++.dg/template/crash57.C (working copy) @@ -7,4 +7,4 @@ template struct B template struct C; // { dg-error "token" } }; -A a; // { dg-error "type/value mismatch|constant|declaration" } +A a; // { dg-error "type" }