re PR c++/27430 (ICE on array of voids as template parameter)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sat, 6 May 2006 00:40:40 +0000 (00:40 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sat, 6 May 2006 00:40:40 +0000 (00:40 +0000)
PR c++/27430
* pt.c (process_template_parm): Handle erroneous non-type parameters.

* g++.dg/template/void1.C: New test.

From-SVN: r113572

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

index 31e40dedf6a4c00d602eecd2a466b9ce831b0f4a..2fcb8934171d67cc7c0ceaae2406061fdad3df0f 100644 (file)
@@ -1,5 +1,8 @@
 2006-05-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/27430
+       * pt.c (process_template_parm): Handle erroneous non-type parameters.
+
        PR c++/27423
        * typeck.c (convert_for_initialization): Skip erroneous types.
 
index 7b814aef8b64a160d222d2e25432a01051873485..614de414cc0c3135bfb103f3d409bc68d186cde5 100644 (file)
@@ -2347,18 +2347,23 @@ process_template_parm (tree list, tree next, bool is_non_type)
 
       SET_DECL_TEMPLATE_PARM_P (parm);
 
-      /* [temp.param]
+      if (TREE_TYPE (parm) == error_mark_node)
+       TREE_TYPE (parm) = void_type_node;
+      else
+      {
+       /* [temp.param]
 
-        The top-level cv-qualifiers on the template-parameter are
-        ignored when determining its type.  */
-      TREE_TYPE (parm) = TYPE_MAIN_VARIANT (TREE_TYPE (parm));
+          The top-level cv-qualifiers on the template-parameter are
+          ignored when determining its type.  */
+       TREE_TYPE (parm) = TYPE_MAIN_VARIANT (TREE_TYPE (parm));
+       if (invalid_nontype_parm_type_p (TREE_TYPE (parm), 1))
+         TREE_TYPE (parm) = void_type_node;
+      }
 
       /* A template parameter is not modifiable.  */
       TREE_CONSTANT (parm) = 1;
       TREE_INVARIANT (parm) = 1;
       TREE_READONLY (parm) = 1;
-      if (invalid_nontype_parm_type_p (TREE_TYPE (parm), 1))
-       TREE_TYPE (parm) = void_type_node;
       decl = build_decl (CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
       TREE_CONSTANT (decl) = 1;
       TREE_INVARIANT (decl) = 1;
index a51b52d0882785487dba8e6dde74746e71149b26..d259e40353203c212b7c3ee438289e0f84ad86cc 100644 (file)
@@ -1,5 +1,8 @@
 2006-05-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/27430
+       * g++.dg/template/void1.C: New test.
+
        PR c++/27423
        * g++.dg/other/void2.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/void1.C b/gcc/testsuite/g++.dg/template/void1.C
new file mode 100644 (file)
index 0000000..732e9d0
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/27430
+// { dg-do compile }
+
+template<void[]> struct A;  // { dg-error "array of void" }