semantics.c (finish_switch_cond): Handle error cases gracefully.
authorMartin v. Löwis <loewis@informatik.hu-berlin.de>
Sat, 13 Mar 1999 01:16:36 +0000 (01:16 +0000)
committerMartin v. Löwis <loewis@gcc.gnu.org>
Sat, 13 Mar 1999 01:16:36 +0000 (01:16 +0000)
        * semantics.c (finish_switch_cond): Handle error cases gracefully.
        Detected by g++.law/enum5.C
        * typeck.c (build_modify_expr): Check for errors after resolving
        offsets. Detected by g++.brendan/static1.C
        * decl.c (complete_array_type): Ignore initial_value if it is an
        error. Detected by g++.benjamin/17930.C
        * typeck2.c (process_init_constructor): Return error if one argument
        is in error. Detected by g++.benjamin/13478.C

From-SVN: r25740

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/semantics.c
gcc/cp/typeck.c
gcc/cp/typeck2.c

index d24c458cd4b1909b358db203cd24c7a2db8c0ecc..0f5a3bd5ce94ab5cbc0d2bfe1423778a29093204 100644 (file)
@@ -1,3 +1,17 @@
+1999-03-13  Martin von Löwis  <loewis@informatik.hu-berlin.de>
+
+       * semantics.c (finish_switch_cond): Handle error cases gracefully.
+       Detected by g++.law/enum5.C
+
+       * typeck.c (build_modify_expr): Check for errors after resolving
+       offsets. Detected by g++.brendan/static1.C
+
+       * decl.c (complete_array_type): Ignore initial_value if it is an
+       error. Detected by g++.benjamin/17930.C 
+
+       * typeck2.c (process_init_constructor): Return error if one argument
+       is in error. Detected by g++.benjamin/13478.C
+
 1999-03-12  Martin von Löwis  <loewis@informatik.hu-berlin.de>
 
        * decl.c (select_decl): Allow class templates when we need types.
index 5eca402cc0b5d8d5b08c6de953cc27cb839d2cba..1de303d3c0e7df853fb653f448513ffea5b5bb4c 100644 (file)
@@ -8259,6 +8259,8 @@ complete_array_type (type, initial_value, do_default)
          /* Make an error message unless that happened already.  */
          if (initial_value != error_mark_node)
            value = 1;
+         else
+           initial_value = NULL_TREE;
 
          /* Prevent further error messages.  */
          maxindex = build_int_2 (0, 0);
index 6471fd15866f43f27be49a1a783b3294c496becb..0e028d2bdb7662828ec53459c27db5fa9d20c462 100644 (file)
@@ -490,12 +490,20 @@ finish_switch_cond (cond)
       r = build_min_nt (SWITCH_STMT, cond, NULL_TREE);
       add_tree (r);
     }
-  else
+  else if (cond != error_mark_node)
     {
       emit_line_note (input_filename, lineno);
       c_expand_start_case (cond);
       r = NULL_TREE;
     }
+  else
+    {
+      /* The code is in error, but we don't want expand_end_case to
+         crash. */
+      c_expand_start_case (boolean_false_node);
+      r = NULL_TREE;
+    }
+
   push_switch ();
 
   /* Don't let the tree nodes for COND be discarded by
index 463fcd4abc4dcace21a5c293d72071c98e627c7a..0732bc800fe1e06f5faa9b7033e1eed89a6595d9 100644 (file)
@@ -5920,6 +5920,9 @@ build_modify_expr (lhs, modifycode, rhs)
       olhstype = lhstype = TREE_TYPE (lhs);
     }
 
+  if (lhs == error_mark_node)
+    return lhs;
+
   if (TREE_CODE (lhstype) == REFERENCE_TYPE
       && modifycode != INIT_EXPR)
     {
index f002bc06c754605d8d99fb2966a04a6a79e57aa4..8051723da7c295dd5e4989cc76a73a429846d5a2 100644 (file)
@@ -932,6 +932,8 @@ process_init_constructor (type, init, elts)
                  tree tail1 = tail;
                  next1 = digest_init (TREE_TYPE (type),
                                       TREE_VALUE (tail), &tail1);
+                 if (next1 == error_mark_node)
+                   return next1;
                  my_friendly_assert
                    (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
                                  TYPE_MAIN_VARIANT (TREE_TYPE (next1))),