re PR c++/48212 ([C++0x] ICE: in non_const_var_error, at cp/semantics.c:6700 on inval...
authorJason Merrill <jason@redhat.com>
Wed, 30 Mar 2011 20:29:13 +0000 (16:29 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 30 Mar 2011 20:29:13 +0000 (16:29 -0400)
PR c++/48212
* semantics.c (non_const_var_error): Just return if DECL_INITIAL
is error_mark_node.

From-SVN: r171748

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C [new file with mode: 0644]

index 8975e6c..5844215 100644 (file)
@@ -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.
index 3300c3f..e444d91 100644 (file)
@@ -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);
index 301b5da..f36c147 100644 (file)
@@ -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 (file)
index 0000000..2094d3e
--- /dev/null
@@ -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" }
+};