java/1136: weak error message when expecting final modifier

joerg.brunsmann@fernuni-hagen.de joerg.brunsmann@fernuni-hagen.de
Wed Dec 20 12:09:00 GMT 2000


>Number:         1136
>Category:       java
>Synopsis:       weak error message when expecting final modifier
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:06:28 PST 2000
>Closed-Date:    Mon Jan 17 14:57:46 PST 2000
>Last-Modified:  Mon Jan 17 15:00:01 PST 2000
>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:

Formerly PR gcj/128

State-Changed-From-To: open->closed
State-Changed-By: apbianco
State-Changed-When: Mon Jan 17 14:57:46 2000
State-Changed-Why:
    Joern's patch has been checked in:
    
      http://gcc.gnu.org/ml/gcc-patches/2000-01/msg00621.html

From: apbianco@cygnus.com
To: apbianco@cygnus.com, java-gnats@sourceware.cygnus.com,
  joerg.brunsmann@fernuni-hagen.de
Cc:  
Subject: Re: gcj/128
Date: 17 Jan 2000 22:57:46 -0000

 Synopsis: weak error message when expecting final modifier
 
 State-Changed-From-To: open->closed
 State-Changed-By: apbianco
 State-Changed-When: Mon Jan 17 14:57:46 2000
 State-Changed-Why:
     Joern's patch has been checked in:
     
       http://gcc.gnu.org/ml/gcc-patches/2000-01/msg00621.html
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=128&database=java
>Unformatted:




More information about the Gcc-prs mailing list