diff options
author | Jason Merrill <jason@redhat.com> | 2011-03-30 16:29:13 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-03-30 16:29:13 -0400 |
commit | ef5daa257f9c64996de02858910471cb666562aa (patch) | |
tree | bc5a4c06ac2c7718769720d69c2c3084bf45f9ab | |
parent | e0f89433aa35e607de82a7d0f96d1a4cb2089717 (diff) | |
download | gcc-ef5daa257f9c64996de02858910471cb666562aa.zip gcc-ef5daa257f9c64996de02858910471cb666562aa.tar.gz gcc-ef5daa257f9c64996de02858910471cb666562aa.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C | 9 |
4 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8975e6c..5844215 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2011-03-30 Jason Merrill <jason@redhat.com> + PR c++/48212 + * semantics.c (non_const_var_error): Just return if DECL_INITIAL + is error_mark_node. + +2011-03-30 Jason Merrill <jason@redhat.com> + PR c++/48369 * semantics.c (potential_constant_expression_1): Handle UNORDERED_EXPR and ORDERED_EXPR. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3300c3f..e444d91 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 301b5da..f36c147 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-03-30 Jason Merrill <jason@redhat.com> + * 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 0000000..2094d3e --- /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" } +}; |