public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/48539] New: Missing warning when messaging a forward-declared class
@ 2011-04-10 11:10 nicola at gcc dot gnu.org
2011-04-10 11:12 ` [Bug objc/48539] " nicola at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-04-10 11:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48539
Summary: Missing warning when messaging a forward-declared
class
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: objc
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: nicola@gcc.gnu.org
The following testcase compiles with no warnings on GCC 4.7.0 20110326:
#include <objc/objc.h>
@class A;
@interface B
{
id isa;
}
+ (void) doSomething;
@end
void test (void)
{
[A doSomething];
}
While clang produces a hard error:
z.m:14:4: warning: receiver 'A' is a forward class and corresponding @interface
may not exist
[A doSomething];
^
z.m:9:1: note: method 'doSomething' is used for the forward class
+ (void) doSomething;
^
1 warning generated.
In this case, the behaviour of clang seems better. @class is really meant to
resolve recursive declarations; it should always be followed by the
corresponding @interface, particularly if you are going to message the class or
objects of the class.
I would say that GCC should produce at least a warning in this case!
There's also the issue of whether the following testcase should also produce
a warning:
#include <objc/objc.h>
@class A;
@interface B
{
id isa;
}
- (void) doSomething;
@end
void test (A *x)
{
[x doSomething];
}
This is slightly different in that it is an instance message, as opposed to
a class message. Neither GCC nor clang produce any warning or error here, but
it sounds like a warning similar to the one above would be very appropriate.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug objc/48539] Missing warning when messaging a forward-declared class
2011-04-10 11:10 [Bug objc/48539] New: Missing warning when messaging a forward-declared class nicola at gcc dot gnu.org
@ 2011-04-10 11:12 ` nicola at gcc dot gnu.org
2011-06-02 18:54 ` nicola at gcc dot gnu.org
2011-06-02 18:59 ` nicola at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-04-10 11:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48539
Nicola Pero <nicola at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.04.10 11:11:54
Ever Confirmed|0 |1
--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-04-10 11:11:54 UTC ---
Yes, it's confirmed with both
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
and
gcc (GCC) 4.7.0 20110326 (experimental)
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug objc/48539] Missing warning when messaging a forward-declared class
2011-04-10 11:10 [Bug objc/48539] New: Missing warning when messaging a forward-declared class nicola at gcc dot gnu.org
2011-04-10 11:12 ` [Bug objc/48539] " nicola at gcc dot gnu.org
@ 2011-06-02 18:54 ` nicola at gcc dot gnu.org
2011-06-02 18:59 ` nicola at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-06-02 18:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48539
--- Comment #2 from Nicola Pero <nicola at gcc dot gnu.org> 2011-06-02 18:54:34 UTC ---
Author: nicola
Date: Thu Jun 2 18:54:32 2011
New Revision: 174575
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174575
Log:
In gcc/objc/:
2011-06-02 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/48539
* objc-act.c (objc_finish_message_expr): Warn if messaging a class
that was only declared using @class without an @interface. Warn
if messaging an instance of a class that was only declared using
@class without an @interface, unless the receiver was also typed
with a protocol list.
In gcc/testsuite/:
2011-06-02 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/48539
* objc.dg/method-5.m: Updated.
* objc.dg/method-19.m: Updated.
* objc.dg/method-lookup-1.m: New.
* obj-c++.dg/method-6.mm: Updated.
* obj-c++.dg/method-7.mm: Updated.
* obj-c++.dg/method-lookup-1.mm: New.
Added:
trunk/gcc/testsuite/obj-c++.dg/method-lookup-1.mm
trunk/gcc/testsuite/objc.dg/method-lookup-1.m
Modified:
trunk/gcc/objc/ChangeLog
trunk/gcc/objc/objc-act.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/obj-c++.dg/method-6.mm
trunk/gcc/testsuite/obj-c++.dg/method-7.mm
trunk/gcc/testsuite/objc.dg/method-19.m
trunk/gcc/testsuite/objc.dg/method-5.m
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug objc/48539] Missing warning when messaging a forward-declared class
2011-04-10 11:10 [Bug objc/48539] New: Missing warning when messaging a forward-declared class nicola at gcc dot gnu.org
2011-04-10 11:12 ` [Bug objc/48539] " nicola at gcc dot gnu.org
2011-06-02 18:54 ` nicola at gcc dot gnu.org
@ 2011-06-02 18:59 ` nicola at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-06-02 18:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48539
Nicola Pero <nicola at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.7.0
Resolution| |FIXED
--- Comment #3 from Nicola Pero <nicola at gcc dot gnu.org> 2011-06-02 18:58:57 UTC ---
Resolved on trunk.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-02 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-10 11:10 [Bug objc/48539] New: Missing warning when messaging a forward-declared class nicola at gcc dot gnu.org
2011-04-10 11:12 ` [Bug objc/48539] " nicola at gcc dot gnu.org
2011-06-02 18:54 ` nicola at gcc dot gnu.org
2011-06-02 18:59 ` nicola at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).