aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2004-08-16 23:57:55 +0000
committerTom Tromey <tromey@gcc.gnu.org>2004-08-16 23:57:55 +0000
commit16d85b639cd5abc3662f49b02e28c4fe7136587f (patch)
treeb41245ef4d33c6bdd7275c286a3b8197e2628676 /gcc/java
parent0e5b1376243861b0dea368f99d1e66fc73c3099d (diff)
downloadgcc-16d85b639cd5abc3662f49b02e28c4fe7136587f.zip
gcc-16d85b639cd5abc3662f49b02e28c4fe7136587f.tar.gz
gcc-16d85b639cd5abc3662f49b02e28c4fe7136587f.tar.bz2
re PR java/8473 (syntax error on anonymous array subscript)
PR java/8473: * parse.y (primary): Changed for initialized and uninitialized array creations. (array_access): Handle array_creation_initialized. (array_creation_expression): Split into array_creation_initialized and array_creation_uninitialized. From-SVN: r86087
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog9
-rw-r--r--gcc/java/parse.y30
2 files changed, 34 insertions, 5 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 761c886..c321073 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,12 @@
+2004-08-16 Tom Tromey <tromey@redhat.com>
+
+ PR java/8473:
+ * parse.y (primary): Changed for initialized and uninitialized
+ array creations.
+ (array_access): Handle array_creation_initialized.
+ (array_creation_expression): Split into
+ array_creation_initialized and array_creation_uninitialized.
+
2004-08-16 Andrew Haley <aph@redhat.com>
* jcf-write.c (find_constant_index): Canonicalize NaNs when
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 8e0d319..2073ce4 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -543,8 +543,8 @@ static GTY(()) tree src_parse_roots[1];
if_then_else_statement_nsi while_statement_nsi
for_statement_nsi statement_expression_list for_init
for_update statement_expression expression_statement
- primary_no_new_array expression primary
- array_creation_expression array_type
+ primary_no_new_array expression primary array_type
+ array_creation_initialized array_creation_uninitialized
class_instance_creation_expression field_access
method_invocation array_access something_dot_new
argument_list postfix_expression while_expression
@@ -1945,7 +1945,8 @@ finally:
/* 19.12 Production from 15: Expressions */
primary:
primary_no_new_array
-| array_creation_expression
+| array_creation_uninitialized
+| array_creation_initialized
;
primary_no_new_array:
@@ -2106,7 +2107,7 @@ argument_list:
{yyerror ("Missing term"); RECOVER;}
;
-array_creation_expression:
+array_creation_uninitialized:
NEW_TK primitive_type dim_exprs
{ $$ = build_newarray_node ($2, $3, 0); }
| NEW_TK class_or_interface_type dim_exprs
@@ -2115,9 +2116,16 @@ array_creation_expression:
{ $$ = build_newarray_node ($2, $3, pop_current_osb (ctxp));}
| NEW_TK class_or_interface_type dim_exprs dims
{ $$ = build_newarray_node ($2, $3, pop_current_osb (ctxp));}
+| NEW_TK error CSB_TK
+ {yyerror ("'[' expected"); DRECOVER ("]");}
+| NEW_TK error OSB_TK
+ {yyerror ("']' expected"); RECOVER;}
+;
+
+array_creation_initialized:
/* Added, JDK1.1 anonymous array. Initial documentation rule
modified */
-| NEW_TK class_or_interface_type dims array_initializer
+ NEW_TK class_or_interface_type dims array_initializer
{
char *sig;
int osb = pop_current_osb (ctxp);
@@ -2271,6 +2279,8 @@ array_access:
{ $$ = build_array_ref ($2.location, $1, $3); }
| primary_no_new_array OSB_TK expression CSB_TK
{ $$ = build_array_ref ($2.location, $1, $3); }
+| array_creation_initialized OSB_TK expression CSB_TK
+ { $$ = build_array_ref ($2.location, $1, $3); }
| name OSB_TK error
{
yyerror ("Missing term and ']' expected");
@@ -2291,6 +2301,16 @@ array_access:
yyerror ("']' expected");
DRECOVER(array_access);
}
+| array_creation_initialized OSB_TK error
+ {
+ yyerror ("Missing term and ']' expected");
+ DRECOVER(array_access);
+ }
+| array_creation_initialized OSB_TK expression error
+ {
+ yyerror ("']' expected");
+ DRECOVER(array_access);
+ }
;
postfix_expression: