PATCH: fix for jv-scan
Tom Tromey
tromey@cygnus.com
Fri Jan 8 11:52:00 GMT 1999
I'm committing the appended patch. It fixes a bug so that jv-scan can
recognize main when declared with an arguments like `String args[]'
(previously it only recognized the form `String[] args').
1999-01-05 Tom Tromey <tromey@cygnus.com>
* parse-scan.y (variable_declarator_id): Set or increment
bracket_count.
(bracket_count): New global.
(formal_parameter): Handle case where bracket pairs trail variable
declarator id.
Tom
Index: parse-scan.y
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/java/parse-scan.y,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 parse-scan.y
--- parse-scan.y 1998/12/17 20:52:04 1.5.2.2
+++ parse-scan.y 1999/01/08 19:45:47
@@ -1,5 +1,5 @@
/* Parser grammar for quick source code scan of Java(TM) language programs.
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
This file is part of GNU CC.
@@ -74,6 +74,10 @@
/* Record modifier uses */
static int modifier_value;
+/* Keep track of number of bracket pairs after a variable declarator
+ id. */
+static int bracket_count;
+
/* Record a method declaration */
struct method_declarator {
char *method_name;
@@ -406,8 +410,9 @@
variable_declarator_id:
identifier
- { USE_ABSORBER; }
+ { bracket_count = 0; USE_ABSORBER; }
| variable_declarator_id OSB_TK CSB_TK
+ { ++bracket_count; }
;
variable_initializer:
@@ -463,10 +468,32 @@
type variable_declarator_id
{
USE_ABSORBER;
- $$ = $1;
+ if (bracket_count)
+ {
+ int i;
+ char *n = xmalloc (bracket_count + 1 + strlen ($$));
+ for (i = 0; i < bracket_count; ++i)
+ n[i] = '[';
+ strcpy (n + bracket_count, $$);
+ $$ = n;
+ }
+ else
+ $$ = $1;
}
| modifiers type variable_declarator_id /* Added, JDK1.1 final locals */
- { $$ = $2; }
+ {
+ if (bracket_count)
+ {
+ int i;
+ char *n = xmalloc (bracket_count + 1 + strlen ($$));
+ for (i = 0; i < bracket_count; ++i)
+ n[i] = '[';
+ strcpy (n + bracket_count, $$);
+ $$ = n;
+ }
+ else
+ $$ = $2;
+ }
;
throws:
More information about the Gcc-patches
mailing list