This is the mail archive of the mailing list for the GCC 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]

Patch: PR 8003

This patch fixes PR 8003.

In this PR, a syntax error causes gcj to SEGV.  It happens because
when trying to give a nicer error message, we reference `java_lval' in
an invalid way -- we use the incorrect field.  (java_lval is a union,
and the `node' field is not always valid.  That is what happens in
this case.)

I tried fixing this a different way.  I added a new
variable_declarator_id rule which matched (at the end)
`OSB_TK expression error'.  This let us continue to print the "can't
specify array dimension" error.  However, this has the side effect of
giving a different error if an invalid expression is used after the
`['.  It seems weird to give such an error if, after fixing the
expression, the result is still invalid.

Based on this, I chose the simpler, but somewhat less friendly,
approach of simply emitting the "missing ]" error in all cases.

Ok to commit?


Index: ChangeLog
from  Tom Tromey  <>

	* parse.y (variable_declarator_id): Simplify error path for
	array declarator error.  For PR java/8003.

Index: parse.y
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.395
diff -u -r1.395 parse.y
--- parse.y 11 Sep 2002 19:53:14 -0000 1.395
+++ parse.y 23 Sep 2002 06:02:01 -0000
@@ -1000,12 +1001,7 @@
 		{yyerror ("Invalid declaration"); DRECOVER(vdi);}
 |	variable_declarator_id OSB_TK error
-		  tree node = java_lval.node;
-		  if (node && (TREE_CODE (node) == INTEGER_CST
-			       || TREE_CODE (node) == EXPR_WITH_FILE_LOCATION))
-		    yyerror ("Can't specify array dimension in a declaration");
-		  else
-		    yyerror ("']' expected");
+		  yyerror ("']' expected");
 |	variable_declarator_id CSB_TK error

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