This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR c++/36411: [4.4 regression] ICE with invalid template template parameter
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: jason at redhat dot com
- Date: Mon, 23 Feb 2009 09:22:42 -0800
- Subject: PATCH: PR c++/36411: [4.4 regression] ICE with invalid template template parameter
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
We crash on invalid template template parameter. This patch checks it.
No regressions on Linux/x86-64. OK for trunk?
Thanks.
H.J.
----
gcc/cp
2009-02-23 H.J. Lu <hongjiu.lu@intel.com>
PR c++/36411
* pt.c (coerce_template_template_parms): Return 0 if parameter
is error_mark_node.
gcc/testsuite/
2009-02-23 H.J. Lu <hongjiu.lu@intel.com>
PR c++/36411
* g++.dg/template/void14.C: New.
--- gcc/cp/pt.c.pr36411 2009-02-14 06:42:19.000000000 -0800
+++ gcc/cp/pt.c 2009-02-22 18:42:47.000000000 -0800
@@ -4756,6 +4756,9 @@ coerce_template_template_parms (tree par
{
parm = TREE_VALUE (TREE_VEC_ELT (parm_parms, nparms - 1));
+ if (parm == error_mark_node)
+ return 0;
+
switch (TREE_CODE (parm))
{
case TEMPLATE_DECL:
--- gcc/testsuite/g++.dg/template/void14.C.pr36411 2009-02-23 09:14:33.000000000 -0800
+++ gcc/testsuite/g++.dg/template/void14.C 2009-02-23 09:17:55.000000000 -0800
@@ -0,0 +1,9 @@
+// PR 36411
+// { dg-do compile }
+
+template<template<void> class> struct A // { dg-error "not a valid type" }
+{
+ template<template<int> class T> A<T> foo(); // { dg-error "type/value mismatch" }
+ // { dg-error "expected a template of type" "template" { target *-*-* } 6 }
+ // { dg-error "invalid type" "declaration" { target *-*-* } 6 }
+};