This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: check-init -vs- SWITCH_HAS_DEFAULT
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Per Bothner <per at bothner dot com>
- Date: 10 Dec 2001 13:47:45 -0700
- Subject: Patch: check-init -vs- SWITCH_HAS_DEFAULT
- Reply-to: tromey at redhat dot com
Per, et al --
Here's an updated version of my fix for PR 1328.
This one backs out yesterday's change and instead uses SWITCH_HAS_DEFAULT.
Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* check-init.c (check_init) [SWITCH_EXPR]: Back out fix from
12-09; use SWITCH_HAS_DEFAULT instead.
Index: check-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/check-init.c,v
retrieving revision 1.39
diff -u -r1.39 check-init.c
--- check-init.c 2001/12/10 04:28:28 1.39
+++ check-init.c 2001/12/10 20:40:39
@@ -429,9 +429,6 @@
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. */
@@ -689,9 +686,7 @@
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);
@@ -699,19 +694,14 @@
alt.block = exp;
check_init (TREE_OPERAND (exp, 1), before);
done_alternative (before, &alt);
- if (! current_switch_has_default)
- {
- done_alternative (alt.saved, &alt);
- }
+ if (! SWITCH_HAS_DEFAULT (exp))
+ 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 DEFAULT_EXPR:
- current_switch_has_default = 1;
- /* .. then fall through ... */
case CASE_EXPR:
+ case DEFAULT_EXPR:
{
int i;
struct alternatives *alt = alternatives;