Bug 19674 - Empty declaration through semicolon (;) causes compile failure
Summary: Empty declaration through semicolon (;) causes compile failure
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks: 18131
  Show dependency treegraph
 
Reported: 2005-01-28 18:08 UTC by Mark Wielaard
Modified: 2005-07-06 19:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-04-30 16:11:11


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2005-01-28 18:08:25 UTC
The following program doesn't compile:

public interface OutSideInterface
{
  public interface InsideInterface
  {
    void m(int p, int p2);
  };
}

Note the empty statement (semicolon) on line 6.
This is legal (jikes accepts it) but deprecated.

Compiling with -C gives:

OutSideInterface.java:6: error: '{' expected.
     };
      ^
OutSideInterface.java:7: error: Class or interface declaration expected.
   }
   ^
2 errors

Reported by Jerry Haltom.


With -Wextraneous-semicolon the compiler does see that this is just an declaration:

OutSideInterface.java:6: warning: An empty declaration is a deprecated feature
that should not be used.
Comment 1 dog@bluezoo.org 2005-01-28 18:19:21 UTC
The relevant JLS production is ClassMemberDeclaration:

http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#18988
Comment 2 Andrew Pinski 2005-01-28 19:04:19 UTC
Confirmed.
Comment 3 Bryce McKinlay 2005-06-18 01:50:44 UTC
I'm testing a patch.
Comment 4 CVS Commits 2005-07-05 21:10:13 UTC
Subject: Bug 19674

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bryce@gcc.gnu.org	2005-07-05 21:09:58

Modified files:
	gcc/java       : ChangeLog parse.y 
	libjava        : ChangeLog 
Added files:
	libjava/testsuite/libjava.compile: PR19674.java 

Log message:
	2005-07-05  Bryce McKinlay  <mckinlay@redhat.com>
	
	PR java/19674
	* parse.y (interface_member_declaration): Allow empty statements in
	interface declarations.
	
	2005-07-05  Bryce McKinlay  <mckinlay@redhat.com>
	
	* testsuite/libjava.compile/PR19674.java: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1640&r2=1.1641
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.545&r2=1.546
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3690&r2=1.3691
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/PR19674.java.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Bryce McKinlay 2005-07-06 19:05:53 UTC
Fixed in HEAD
Comment 6 CVS Commits 2005-07-12 22:35:13 UTC
Subject: Bug 19674

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-07-12 22:35:04

Modified files:
	gcc/java       : ChangeLog jvspec.c parse-scan.y 

Log message:
	PR java/19674:
	* parse-scan.y (interface_member_declaration): Added
	empty_statement.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1644&r2=1.1645
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/jvspec.c.diff?cvsroot=gcc&r1=1.70&r2=1.71
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse-scan.y.diff?cvsroot=gcc&r1=1.41&r2=1.42