From 0db982bee5681b334b0b2cc460920c542dbbc964 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sat, 13 Mar 1999 01:16:36 +0000 Subject: [PATCH] semantics.c (finish_switch_cond): Handle error cases gracefully. * 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 | 14 ++++++++++++++ gcc/cp/decl.c | 2 ++ gcc/cp/semantics.c | 10 +++++++++- gcc/cp/typeck.c | 3 +++ gcc/cp/typeck2.c | 2 ++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d24c458cd4b..0f5a3bd5ce9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +1999-03-13 Martin von Löwis + + * 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 * decl.c (select_decl): Allow class templates when we need types. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5eca402cc0b..1de303d3c0e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6471fd15866..0e028d2bdb7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 463fcd4abc4..0732bc800fe 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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) { diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index f002bc06c75..8051723da7c 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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))), -- 2.30.2