From: Paolo Carlini Date: Fri, 20 Jan 2012 17:21:19 +0000 (+0000) Subject: re PR c++/51402 (ICE with invalid template parameter) X-Git-Tag: releases/gcc-4.7.0~910 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b968b19221d537229241171266b682e5827c51d7;p=thirdparty%2Fgcc.git re PR c++/51402 (ICE with invalid template parameter) /cp 2012-01-20 Paolo Carlini PR c++/51402 * pt.c (lookup_template_class_1): Check context returned by tsubst for error_mark_node. /testsuite 2012-01-20 Paolo Carlini PR c++/51402 * g++.dg/template/crash110.C: New. From-SVN: r183345 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 610baa2ede2a..94e6dc9f1ade 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-01-20 Paolo Carlini + + PR c++/51402 + * pt.c (lookup_template_class_1): Check context returned by + tsubst for error_mark_node. + 2012-01-19 Kai Tietz PR c++/51344 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 87ec5f5103ef..a4460f1d87b1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1,6 +1,6 @@ /* Handle parameterized types (templates) for GNU C++. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 + 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Rewritten by Jason Merrill (jason@cygnus.com). @@ -7466,6 +7466,9 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, context = tsubst (DECL_CONTEXT (gen_tmpl), arglist, complain, in_decl); + if (context == error_mark_node) + return error_mark_node; + if (!context) context = global_namespace; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8da1e549ba7c..7db1f790b156 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-20 Paolo Carlini + + PR c++/51402 + * g++.dg/template/crash110.C: New. + 2012-01-20 Rainer Orth * gcc.misc-tests/gcov-14.c: Skip on alpha*-dec-osf*. diff --git a/gcc/testsuite/g++.dg/template/crash110.C b/gcc/testsuite/g++.dg/template/crash110.C new file mode 100644 index 000000000000..d0a4b4ddcb8b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash110.C @@ -0,0 +1,7 @@ +// PR c++/51402 + +template struct A // { dg-error "not a valid type" } +{ + template struct B {}; + template struct B {}; +};