Hi,

this low priority ICE on invalid happens only in c++98 mode but I think we can as well avoid it and have consistent error recovery across std modes. Essentially, the VAR_DECL for 'b' with erroneous TREE_TYPE (the type is incomplete) reaches cxx_eval_constant_expression and we ICE when we use COMPLETE_TYPE_P on the TREE_TYPE itself. I think we can - consistently across std modes - catch the erroneous type quite a bit earlier, midway in finish_case_label, thus before the case_conversion call which eventually leads to the ICE. Tested x86_64-linux.

Thanks, Paolo.

/////////////////////

/cp
2018-08-28  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/86546
        * decl.c (finish_case_label): If the type is erroneous early
        return error_mark_node.

/testsuite
2018-08-28  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/86546
        * g++.dg/other/switch4.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 263914)
+++ cp/decl.c   (working copy)
@@ -3662,6 +3662,8 @@ finish_case_label (location_t loc, tree low_value,
     return error_mark_node;
 
   type = SWITCH_STMT_TYPE (switch_stack->switch_stmt);
+  if (type == error_mark_node)
+    return error_mark_node;
 
   low_value = case_conversion (type, low_value);
   high_value = case_conversion (type, high_value);
Index: testsuite/g++.dg/other/switch4.C
===================================================================
--- testsuite/g++.dg/other/switch4.C    (nonexistent)
+++ testsuite/g++.dg/other/switch4.C    (working copy)
@@ -0,0 +1,6 @@
+// PR c++/86546
+
+class a b;  // { dg-error "aggregate" }
+void c() {
+  switch ()  // { dg-error "expected" }
+  case b  // { dg-error "expected" }

Reply via email to