This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: fix enum parsing
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 20 Sep 2005 11:03:50 -0600
- Subject: [gcjx] Patch: FYI: fix enum parsing
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a couple of bugs in 'enum' parsing pointed out by jacks.
(Note that enums still don't work, due to a bug in generic type
instantiation, so you have to read the actual failure messages in
jacks to see this bug.)
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/enum.cc (resolve_hook): Don't reject top-level classes.
* source/parse.cc (enum_body): Allow empty enum body. Handle
trailing commas and semicolons properly.
(enum_declaration): Call set_containing_class.
(annotation_type_declaration): Likewise.
Index: model/enum.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/enum.cc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 enum.cc
--- model/enum.cc 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/enum.cc 20 Sep 2005 17:07:17 -0000
@@ -1,6 +1,6 @@
// Represent an enum class.
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
@@ -109,7 +109,7 @@
void
model_enum::resolve_hook (resolution_scope *scope)
{
- if (declaring_class && ! declaring_class->static_p ())
+ if (declaring_class && declaring_class->inner_p ())
std::cerr << error ("enum invalid in inner class %1")
% declaring_class;
Index: source/parse.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/source/Attic/parse.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 parse.cc
--- source/parse.cc 12 Sep 2005 01:41:47 -0000 1.1.2.4
+++ source/parse.cc 20 Sep 2005 17:07:21 -0000
@@ -2917,7 +2917,7 @@
{
require (TOKEN_OPEN_BRACE);
- if (peek () != TOKEN_SEMI)
+ if (peek () != TOKEN_SEMI && peek () != TOKEN_CLOSE_BRACE)
{
while (true)
{
@@ -2935,12 +2935,15 @@
if (peek () != TOKEN_COMMA)
break;
assume (TOKEN_COMMA);
+ // We might have a trailing comma.
+ if (peek () == TOKEN_SEMI || peek () == TOKEN_CLOSE_BRACE)
+ break;
}
}
if (peek () == TOKEN_SEMI)
{
- require (TOKEN_SEMI);
+ assume (TOKEN_SEMI);
// We push a new empty label to indicate to inner methods that
// there is a class boundary on the label stack. This lets us
@@ -2963,7 +2966,9 @@
{
location where = assume (TOKEN_ENUM);
ref_enum result (new model_enum (where));
+ result->set_compilation_unit (unit);
result->set_name (identifier ());
+ set_containing_class (result);
result->set_modifiers (mods);
if (peek () == TOKEN_IMPLEMENTS)
@@ -2984,9 +2989,10 @@
location where = require (TOKEN_INTERFACE);
ref_annotation_type result (new model_annotation_type (where));
+ result->set_compilation_unit (unit);
result->set_name (identifier ());
+ set_containing_class (result);
result->set_modifiers (mods);
- result->set_compilation_unit (unit);
class_body (result, true);
return result;
}