From 1beb527252452165fc7b441562f803c72fdc666a Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 23 Jan 2012 17:56:42 +0000 Subject: [PATCH] re PR c++/51398 (ICE with invalid template parameter) /cp 2012-01-23 Paolo Carlini PR c++/51398 * pt.c (parameter_of_template_p): Skip error_mark_node parameters. /testsuite 2012-01-23 Paolo Carlini PR c++/51398 * g++.dg/template/crash111.C: New. From-SVN: r183445 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/crash111.C | 6 ++++++ 4 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/crash111.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b6bf88f4caa..13f34845818 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2012-01-23 Paolo Carlini + + PR c++/51398 + * pt.c (parameter_of_template_p): Skip error_mark_node parameters. + 2012-01-23 Jason Merrill PR c++/51925 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a4460f1d87b..e440be706cf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8157,6 +8157,9 @@ parameter_of_template_p (tree parm, tree templ) for (i = 0; i < TREE_VEC_LENGTH (parms); ++i) { tree p = TREE_VALUE (TREE_VEC_ELT (parms, i)); + if (p == error_mark_node) + continue; + if (parm == p || (DECL_INITIAL (parm) && DECL_INITIAL (parm) == DECL_INITIAL (p))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41929df32cc..37a56147f17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-23 Paolo Carlini + + PR c++/51398 + * g++.dg/template/crash111.C: New. + 2012-01-23 Arnaud Charlet * ada/acats/tests/cxh/cxh1001.a: Removed, test not suitable on all diff --git a/gcc/testsuite/g++.dg/template/crash111.C b/gcc/testsuite/g++.dg/template/crash111.C new file mode 100644 index 00000000000..f711260ee69 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash111.C @@ -0,0 +1,6 @@ +// PR c++/51398 + +template struct A // { dg-error "not a valid type" } +{ + static const int i = N; +}; -- 2.30.2