This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: avoid shadowing errors with enums
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 11 Sep 2005 19:36:00 -0600
- Subject: [gcjx] Patch: FYI: avoid shadowing errors with enums
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a bug where we could emit an incorrect error about
shadowing when parsing an enum body. This could happen because we
didn't properly push a new scope. I believe this was found via jacks,
though it has been a while and I don't really remember.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* source/parse.cc (enum_body): Push a new class scope when parsing
body.
Index: source/parse.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/source/Attic/parse.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 parse.cc
--- source/parse.cc 13 Feb 2005 03:46:45 -0000 1.1.2.3
+++ source/parse.cc 12 Sep 2005 01:39:00 -0000
@@ -2941,8 +2941,14 @@
if (peek () == TOKEN_SEMI)
{
require (TOKEN_SEMI);
- // FIXME: don't we need to push a new scope like
- // we do in class_body()?
+
+ // We push a new empty label to indicate to inner methods that
+ // there is a class boundary on the label stack. This lets us
+ // avoid errors about shadowing when they are not warranted.
+ stack_temporary<Ilabel *> push_scope (label_stack, NULL);
+
+ stack_temporary<model_class *> pusher (class_stack, result.get ());
+
while (peek () != TOKEN_CLOSE_BRACE)
class_body_declaration (result, false);
}