re PR c++/28594 (ICE with invalid template parameter)
authorLee Millward <lee.millward@codesourcery.com>
Tue, 15 Aug 2006 17:21:09 +0000 (17:21 +0000)
committerLee Millward <lmillward@gcc.gnu.org>
Tue, 15 Aug 2006 17:21:09 +0000 (17:21 +0000)
PR c++/28594
* pt.c (process_template_parm): Robustify.
* g++.dg/template/void6.C: New test.

From-SVN: r116160

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/void6.C [new file with mode: 0644]

index 9194192f51d836a9a00f8fd8b58edad863071e44..53efac925404831f1169ca94c70c45c3a76973e8 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-15  Lee Millward  <lee.millward@codesourcery.com>
+
+       PR c++/28594
+       * pt.c (process_template_parm): Robustify.
+       
 2006-08-14  Steve Ellcey  <sje@cup.hp.com>
 
        PR c++/28288
index c744759899b9cac32e8a17c3e404aabfc3151fa1..4c2b45a5a69dfb106e5aceeaf4419c371946a22f 100644 (file)
@@ -2352,19 +2352,24 @@ process_template_parm (tree list, tree parm, bool is_non_type)
 {
   tree decl = 0;
   tree defval;
-  int idx;
+  int idx = 0;
 
   gcc_assert (TREE_CODE (parm) == TREE_LIST);
   defval = TREE_PURPOSE (parm);
 
   if (list)
     {
-      tree p = TREE_VALUE (tree_last (list));
+      tree p = tree_last (list);
+
+      if (p && p != error_mark_node)
+        {
+          p = TREE_VALUE (p);
+          if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
+            idx = TEMPLATE_TYPE_IDX (TREE_TYPE (p));
+          else
+            idx = TEMPLATE_PARM_IDX (DECL_INITIAL (p));
+        }
 
-      if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
-       idx = TEMPLATE_TYPE_IDX (TREE_TYPE (p));
-      else
-       idx = TEMPLATE_PARM_IDX (DECL_INITIAL (p));
       ++idx;
     }
   else
index d88769987e87e24c3f7ae3cf55c5ced245c98854..030212f05e4b4cc79d9d0adace10ebfd771b4c4d 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-15  Lee Millward  <lee.millward@codesourcery.com>
+
+       PR c++/28594
+       * g++.dg/template/void6.C: New test.
+       
 2006-08-15  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c/28649
diff --git a/gcc/testsuite/g++.dg/template/void6.C b/gcc/testsuite/g++.dg/template/void6.C
new file mode 100644 (file)
index 0000000..2d5f7ea
--- /dev/null
@@ -0,0 +1,3 @@
+//PR c++/28594
+
+template<void, int> struct A; // { dg-error "not a valid type" }