gcj/128: weak error message when expecting final modifier

joerg.brunsmann@fernuni-hagen.de joerg.brunsmann@fernuni-hagen.de
Thu Jan 6 09:40:00 GMT 2000


>Number:         128
>Category:       gcj
>Synopsis:       weak error message when expecting final modifier
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 06 09:40:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     joerg.brunsmann@fernuni-hagen.de
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
With the attached patch gcj spits out a 
reasonable error message when parsing this:

public class X {
  void f(public String s) {
  }
}

The patch adds a new rule named 'final' which
accepts only the literal "final" as a valid 
modifier. The rule 'final' might also help the 
rule for 'local_variable_declaration' and hence the
implementation of function declare_local_variables()
>How-To-Repeat:

>Fix:
--- parse.y.orig	Mon Dec 13 06:55:27 1999
+++ parse.y	Tue Jan  4 19:35:50 2000
@@ -946,17 +946,28 @@ formal_parameter:
 		{
 		  $$ = build_tree_list ($2, $1);
 		}
-|	modifiers type variable_declarator_id /* Added, JDK1.1 final parms */
+|	final type variable_declarator_id /* Added, JDK1.1 final parms */
 		{ 
 		  parse_jdk1_1_error ("final parameters");
 		  $$ = build_tree_list ($3, $2);
 		}
 |	type error
 		{yyerror ("Missing identifier"); RECOVER;}
-|	modifiers type error
+|	final type error
 		{
-		  SOURCE_FRONTEND_DEBUG (("Modifiers: %d", $1));
 		  yyerror ("Missing identifier"); RECOVER;
+		}
+;
+
+final:
+	modifiers
+		{
+		  check_modifiers ("Illegal modifier `%s'. Only "
+				   "`final' was expected here",
+				   $1, ACC_FINAL);
+		  if ($1 != ACC_FINAL)
+		    MODIFIER_WFL (FINAL_TK) = 
+		      build_wfl_node (NULL_TREE);
 		}
 ;

 

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Java-prs mailing list