aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin v. Löwis <loewis@informatik.hu-berlin.de>1999-03-13 01:16:36 +0000
committerMartin v. Löwis <loewis@gcc.gnu.org>1999-03-13 01:16:36 +0000
commit0db982bee5681b334b0b2cc460920c542dbbc964 (patch)
tree045622ec131250d2de223434afc679ea17570fa1
parentdb7695ef3e803f8a4404e8404ae5bb9710f7e876 (diff)
downloadgcc-0db982bee5681b334b0b2cc460920c542dbbc964.zip
gcc-0db982bee5681b334b0b2cc460920c542dbbc964.tar.gz
gcc-0db982bee5681b334b0b2cc460920c542dbbc964.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/semantics.c10
-rw-r--r--gcc/cp/typeck.c3
-rw-r--r--gcc/cp/typeck2.c2
5 files changed, 30 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d24c458..0f5a3bd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5eca402..1de303d 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 6471fd1..0e028d2 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 463fcd4..0732bc8 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 f002bc0..8051723 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))),