This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
java/1329: Interface methods implementations not always checked
- To: java-gnats at sourceware dot cygnus dot com
- Subject: java/1329: Interface methods implementations not always checked
- From: bryce at albatross dot co dot nz
- Date: 9 Aug 2000 09:54:30 -0000
- Reply-To: bryce at albatross dot co dot nz
>Number: 1329
>Category: java
>Synopsis: Interface methods implementations not always checked
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: tromey
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 20 12:19:04 PST 2000
>Closed-Date: Fri Dec 15 19:46:45 PST 2000
>Last-Modified: Fri Dec 15 19:50:02 PST 2000
>Originator: Bryce McKinlay
>Release: unknown-1.0
>Organization:
>Environment:
>Description:
The following code is illegal because the method a() is
not implemented in the class C. However, gcj does not report
this error if the interface it not an immediate/direct
superinterface. See also PR 278.
interface I1
{
int a();
}
interface I2 extends I1 {}
class C implements I2 {}
>How-To-Repeat:
Compile the example above.
>Fix:
>Release-Note:
>Audit-Trail:
Formerly PR gcj/305
From: Tom Tromey <tromey@cygnus.com>
To: Alexandre Petit-Bianco <apbianco@cygnus.com>
Cc: Java Gnats Server <java-gnats@sourceware.cygnus.com>
Subject: gcj/305
Date: 19 Aug 2000 19:51:05 -0600
Alex, did you see my patch for PR 305?
I don't see a mention of it in Gnats or in gcc-patches. Probably I
forgot to send it.
2000-08-09 Tom Tromey <tromey@cygnus.com>
* parse.y (check_abstract_method_definitions): Now return `int'.
Check implemented interfaces. Fixes PR gcj/305.
Tom
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.200
diff -u -r1.200 parse.y
--- parse.y 2000/08/11 22:01:37 1.200
+++ parse.y 2000/08/20 01:38:52
@@ -276,7 +276,7 @@
static int binop_compound_p PARAMS ((enum tree_code));
static tree search_loop PARAMS ((tree));
static int labeled_block_contains_loop_p PARAMS ((tree, tree));
-static void check_abstract_method_definitions PARAMS ((int, tree, tree));
+static int check_abstract_method_definitions PARAMS ((int, tree, tree));
static void java_check_abstract_method_definitions PARAMS ((tree));
static void java_debug_context_do PARAMS ((int));
static void java_parser_context_push_initialized_field PARAMS ((void));
@@ -5825,13 +5825,15 @@
return 0;
}
-static void
+/* Return 1 if check went ok, 0 otherwise. */
+static int
check_abstract_method_definitions (do_interface, class_decl, type)
int do_interface;
tree class_decl, type;
{
tree class = TREE_TYPE (class_decl);
tree method, end_type;
+ int ok = 1;
end_type = (do_interface ? object_type_node : type);
for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
@@ -5904,13 +5906,27 @@
IDENTIFIER_POINTER (ccn),
(CLASS_INTERFACE (class_decl) ? "interface" : "class"),
IDENTIFIER_POINTER (DECL_NAME (class_decl)));
-
+ ok = 0;
free (t);
-
+
if (saved_wfl)
DECL_NAME (method) = saved_wfl;
}
}
+
+ if (ok && do_interface)
+ {
+ /* Check for implemented interfaces. */
+ int i;
+ tree vector = TYPE_BINFO_BASETYPES (type);
+ for (i = 1; ok && vector && i < TREE_VEC_LENGTH (vector); i++)
+ {
+ tree super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
+ ok = check_abstract_method_definitions (1, class_decl, super);
+ }
+ }
+
+ return ok;
}
/* Check that CLASS_DECL somehow implements all inherited abstract
From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: Java Gnats Server <java-gnats@sourceware.cygnus.com>
Cc:
Subject: Re: gcj/305
Date: Sat, 19 Aug 2000 22:29:43 -0700 (PDT)
Tom Tromey writes:
> Alex, did you see my patch for PR 305? I don't see a mention of it
> in Gnats or in gcc-patches. Probably I forgot to send it.
You sent it to me and Bryce. I read it already but I didn't know what
to think of your comments:
> The problem is that this doesn't keep track of whether we've already
> warned about a given method. It's an ugly-ish problem, I think.
Since I don't have a much better opinion on the problem today, I think
you can check it in. Sorry for the delay.
./A
Responsible-Changed-From-To: apbianco->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Sun Aug 20 09:29:39 2000
Responsible-Changed-Why:
I fixed it.
State-Changed-From-To: open->feedback
State-Changed-By: tromey
State-Changed-When: Sun Aug 20 09:29:39 2000
State-Changed-Why:
I've checked in a gcj patch for this.
Can you try it out & get back to me?
From: tromey@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
java-gnats@sourceware.cygnus.com, tromey@cygnus.com
Cc:
Subject: Re: gcj/305
Date: 20 Aug 2000 16:29:39 -0000
Synopsis: Interface methods implementations not always checked
Responsible-Changed-From-To: apbianco->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Sun Aug 20 09:29:39 2000
Responsible-Changed-Why:
I fixed it.
State-Changed-From-To: open->feedback
State-Changed-By: tromey
State-Changed-When: Sun Aug 20 09:29:39 2000
State-Changed-Why:
I've checked in a gcj patch for this.
Can you try it out & get back to me?
http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=305&database=java
State-Changed-From-To: feedback->closed
State-Changed-By: bryce
State-Changed-When: Fri Dec 15 19:46:45 2000
State-Changed-Why:
This fix is working fine. Thanks.
From: bryce@albatross.co.nz
To: bryce@albatross.co.nz, java-gnats@sourceware.cygnus.com, tromey@cygnus.com
Cc:
Subject: Re: gcj/305
Date: 16 Dec 2000 03:46:45 -0000
Synopsis: Interface methods implementations not always checked
State-Changed-From-To: feedback->closed
State-Changed-By: bryce
State-Changed-When: Fri Dec 15 19:46:45 2000
State-Changed-Why:
This fix is working fine. Thanks.
http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=305&database=java
>Unformatted: