From 5c62e6611d4b12f6fdf10743dd4d691d2d6d8962 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 3 Mar 2011 17:07:28 +0000 Subject: [PATCH] re PR c++/47974 (ICE: tree check: expected tree_vec, have error_mark in tsubst_template_args, at cp/pt.c:8969 on invalid code) /cp 2011-03-03 Paolo Carlini PR c++/47974 * pt.c (tsubst_template_args): Check argument t for error_mark_node. /testsuite 2011-03-03 Paolo Carlini PR c++/47974 * g++.dg/template/crash106.C: New. From-SVN: r170658 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 11 ++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/crash106.C | 12 ++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/crash106.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ef766fbff3d..747457a1937 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-03-03 Paolo Carlini + + PR c++/47974 + * pt.c (tsubst_template_args): Check argument t for error_mark_node. + 2011-03-03 Jason Merrill PR c++/47950 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 60b26996c47..c52bb74eba8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8966,9 +8966,14 @@ static tree tsubst_template_args (tree t, tree args, tsubst_flags_t complain, tree in_decl) { tree orig_t = t; - int len = TREE_VEC_LENGTH (t); - int need_new = 0, i, expanded_len_adjust = 0, out; - tree *elts = XALLOCAVEC (tree, len); + int len, need_new = 0, i, expanded_len_adjust = 0, out; + tree *elts; + + if (t == error_mark_node) + return error_mark_node; + + len = TREE_VEC_LENGTH (t); + elts = XALLOCAVEC (tree, len); for (i = 0; i < len; i++) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f7a372fa0a..69b7569c615 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-03 Paolo Carlini + + PR c++/47974 + * g++.dg/template/crash106.C: New. + 2011-03-03 Jakub Jelinek PR c/47963 diff --git a/gcc/testsuite/g++.dg/template/crash106.C b/gcc/testsuite/g++.dg/template/crash106.C new file mode 100644 index 00000000000..c2d117e03a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash106.C @@ -0,0 +1,12 @@ +// PR c++/47974 + +typedef double T; + +struct A +{ + template void foo(); // { dg-error "type" } +}; + +template > struct B {}; // { dg-error "type|declared" } + +B<> b; // { dg-error "type|declaration" } -- 2.30.2