From ef5daa257f9c64996de02858910471cb666562aa Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 30 Mar 2011 16:29:13 -0400 Subject: [PATCH] re PR c++/48212 ([C++0x] ICE: in non_const_var_error, at cp/semantics.c:6700 on invalid code) PR c++/48212 * semantics.c (non_const_var_error): Just return if DECL_INITIAL is error_mark_node. From-SVN: r171748 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 3 +++ gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8975e6cbf26..584421536c0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-30 Jason Merrill + + PR c++/48212 + * semantics.c (non_const_var_error): Just return if DECL_INITIAL + is error_mark_node. + 2011-03-30 Jason Merrill PR c++/48369 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3300c3f5b3a..e444d91267f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6753,6 +6753,9 @@ non_const_var_error (tree r) tree type = TREE_TYPE (r); error ("the value of %qD is not usable in a constant " "expression", r); + /* Avoid error cascade. */ + if (DECL_INITIAL (r) == error_mark_node) + return; if (DECL_DECLARED_CONSTEXPR_P (r)) inform (DECL_SOURCE_LOCATION (r), "%qD used in its own initializer", r); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 301b5da03a8..f36c147e0bd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-03-30 Jason Merrill + * g++.dg/cpp0x/regress/error-recovery1.C: New. + * g++.dg/cpp0x/regress/isnan.C: New. * g++.dg/cpp0x/initlist46.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C b/gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C new file mode 100644 index 00000000000..2094d3e3ebe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C @@ -0,0 +1,9 @@ +// PR c++/48212 +// { dg-options -std=c++0x } + +template < bool > void +foo () +{ + const bool b =; // { dg-error "" } + foo < b > (); // { dg-error "constant expression" } +}; -- 2.30.2