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  <paolo.carl...@oracle.com>

        PR c++/34892
        * pt.c (coerce_template_parms): Check TREE_PURPOSE (parm)
        for error_mark_node.

/testsuite
2012-10-24  Paolo Carlini  <paolo.carl...@oracle.com>

        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<int=..., int=0> 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<typename class T, T = T()> // { dg-error "nested-name-specifier|two 
or more|valid type" }
 struct A {};
 
-template<int> void foo(A<int>);     // { dg-error "mismatch|constant|template 
argument" }
+template<int> void foo(A<int>);     // { 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<typename> struct B
     template<int(> struct C;    // { dg-error "token" }
 };
 
-A<char> a;                      // { dg-error "type/value 
mismatch|constant|declaration" }
+A<char> a;                      // { dg-error "type" }

Reply via email to