From 16d85b639cd5abc3662f49b02e28c4fe7136587f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 16 Aug 2004 23:57:55 +0000 Subject: [PATCH] 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 --- gcc/java/ChangeLog | 9 +++++++++ gcc/java/parse.y | 30 +++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 761c886f728..c321073b438 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,12 @@ +2004-08-16 Tom Tromey + + 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 * jcf-write.c (find_constant_index): Canonicalize NaNs when diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 8e0d3197840..2073ce46ace 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: -- 2.30.2