Patch: RFA: fix for PR java/15656

Tom Tromey tromey@redhat.com
Thu Sep 23 15:10:00 GMT 2004


This is an ad hoc fix for PR 15656.  

It fixes the problem mentioned in the PR.  Basically we could reach an
error state and not set $$; then this would be used unconditionally
later on.

The fix sets $$ to NULL_TREE in a few error rules that relate to the
PR.  There are probably still ways to trigger this crash or a similar
one by following other error paths.

Tested on x86 FC2, using mauve and jacks.

Ok?

Tom


Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR java/15656:
	* parse.y (class_instance_creation_expression): Set `$$' to NULL
	in error parts of rule.
	(unary_expression): Don't call error_if_numeric_overflow when $1
	is NULL.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.506
diff -u -r1.506 parse.y
--- parse.y 22 Sep 2004 10:51:42 -0000 1.506
+++ parse.y 22 Sep 2004 22:31:09 -0000
@@ -2016,17 +2016,22 @@
 		}
 |	something_dot_new identifier OP_TK argument_list CP_TK class_body
 |	NEW_TK error SC_TK
-		{yyerror ("'(' expected"); DRECOVER(new_1);}
+		{$$ = NULL_TREE; yyerror ("'(' expected"); DRECOVER(new_1);}
 |	NEW_TK class_type error
-		{yyerror ("'(' expected"); RECOVER;}
+		{$$ = NULL_TREE; yyerror ("'(' expected"); RECOVER;}
 |	NEW_TK class_type OP_TK error
-		{yyerror ("')' or term expected"); RECOVER;}
+		{$$ = NULL_TREE; yyerror ("')' or term expected"); RECOVER;}
 |	NEW_TK class_type OP_TK argument_list error
-		{yyerror ("')' expected"); RECOVER;}
+		{$$ = NULL_TREE; yyerror ("')' expected"); RECOVER;}
 |	something_dot_new error
-		{YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;}
+		{
+		  $$ = NULL_TREE;
+		  YYERROR_NOW;
+		  yyerror ("Identifier expected");
+		  RECOVER;
+		}
 |	something_dot_new identifier error
-		{yyerror ("'(' expected"); RECOVER;}
+		{$$ = NULL_TREE; yyerror ("'(' expected"); RECOVER;}
 ;
 
 /* Created after JDK1.1 rules originally added to
@@ -2343,7 +2348,8 @@
 unary_expression:
 	trap_overflow_corner_case
 		{
-		  error_if_numeric_overflow ($1);
+		  if ($1)
+		    error_if_numeric_overflow ($1);
 		  $$ = $1;
 		}
 |	MINUS_TK trap_overflow_corner_case



More information about the Java-patches mailing list