This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gcjx] Patch: FYI: avoid shadowing errors with enums


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);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]