summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-10 04:28:28 +0000
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-10 04:28:28 +0000
commit095083f9b63f6e4da69fd07f24d4d8c6ffe72bc2 (patch)
tree73ee10ba948d6110ed04d65fb6a3d591fa635e95
parentc277b64b4a53b4e56e79d5251e14e3c62f7f0562 (diff)
downloadppe42-gcc-095083f9b63f6e4da69fd07f24d4d8c6ffe72bc2.tar.gz
ppe42-gcc-095083f9b63f6e4da69fd07f24d4d8c6ffe72bc2.zip
* check-init.c (current_switch_has_default): New static field.
(check_init): Case DEFAULT_EXPR: Set current_switch_has_default. Case SWITCH_EXPR: Save/restore current_switch_has_default. If no DEFAULT_EXPR seen, simulate a default alternative that copies state. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47833 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/java/ChangeLog7
-rw-r--r--gcc/java/check-init.c14
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index aa5a8dfa2b1..07bf935f635 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,10 @@
+2001-12-09 Per Bothner <per@bothner.com>
+
+ * check-init.c (current_switch_has_default): New static field.
+ (check_init): Case DEFAULT_EXPR: Set current_switch_has_default.
+ Case SWITCH_EXPR: Save/restore current_switch_has_default. If no
+ DEFAULT_EXPR seen, simulate a default alternative that copies state.
+
2001-12-09 Tom Tromey <tromey@redhat.com>
* check-init.c (check_init): Don't allow pre- or post- increment
diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c
index bc73ab2a05b..4b1ab98b0e8 100644
--- a/gcc/java/check-init.c
+++ b/gcc/java/check-init.c
@@ -429,6 +429,9 @@ struct alternatives
struct alternatives * alternatives = NULL;
+/* True if we've seen a DEFAULT_EXPR for the current SWITCH_EXPR. */
+static int current_switch_has_default;
+
/* Begin handling a control flow branch.
BEFORE is the state of [un]assigned variables on entry.
CURRENT is a struct alt to manage the branch alternatives. */
@@ -686,7 +689,9 @@ check_init (exp, before)
case SWITCH_EXPR:
{
struct alternatives alt;
+ int saved_current_switch_has_default = current_switch_has_default;
word buf[2];
+ current_switch_has_default = 0;
check_init (TREE_OPERAND (exp, 0), before);
BEGIN_ALTERNATIVES (before, alt);
alt.saved = ALLOC_BUFFER(buf, num_current_words);
@@ -694,12 +699,19 @@ check_init (exp, before)
alt.block = exp;
check_init (TREE_OPERAND (exp, 1), before);
done_alternative (before, &alt);
+ if (! current_switch_has_default)
+ {
+ done_alternative (alt.saved, &alt);
+ }
FREE_BUFFER(alt.saved, buf);
END_ALTERNATIVES (before, alt);
+ current_switch_has_default = saved_current_switch_has_default;
return;
}
- case CASE_EXPR:
case DEFAULT_EXPR:
+ current_switch_has_default = 1;
+ /* .. then fall through ... */
+ case CASE_EXPR:
{
int i;
struct alternatives *alt = alternatives;
OpenPOWER on IntegriCloud