public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/48527] New: Incorrect list of methods in @protocol used across compilation units
@ 2011-04-09 10:46 nicola at gcc dot gnu.org
  2011-04-09 10:47 ` [Bug objc/48527] " nicola at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-04-09 10:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48527

           Summary: Incorrect list of methods in @protocol used across
                    compilation units
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: objc
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nicola@gcc.gnu.org


I'm using GCC 4.6.0.

The following example shows things working correctly when a protocol is used
in the same compilation unit:

[nicola@lampone ~]$ cat x1.m
#include <objc/runtime.h>

@protocol A
- (void) test;
@end

int main (void)
{
  Protocol *p = @protocol (A);
  struct objc_method_description method = protocol_getMethodDescription (p,
@selector (test),
                                                                         YES,
YES);

  printf ("Protocol name is %s\n", protocol_getName (p));
  printf ("Method is %s, %s\n", sel_getName (method.name), method.types);

  return 0;
}
[nicola@lampone ~]$ gcc x1.m -lobjc
x1.m: In function ‘main’:
x1.m:13:3: warning: incompatible implicit declaration of built-in function
‘printf’ [enabled by default]
[nicola@lampone ~]$ ./a.out 
Protocol name is A
Method is test, v8@0:4
[nicola@lampone ~]$

This shows the protocol being recognized, and the full list of methods being
available when you introspect the protocol. :-)

But, if you move the @protocol to another compilation unit, things stop
working! :-(

[nicola@lampone ~]$ cat x2.m
#include <objc/runtime.h>

@protocol A;

int main (void)
{
  Protocol *p = @protocol (A);
  struct objc_method_description method = protocol_getMethodDescription (p,
@selector (test),
                                                                         YES,
YES);

  printf ("Protocol name is %s\n", protocol_getName (p));
  printf ("Method is %s, %s\n", sel_getName (method.name), method.types);

  return 0;
}
[nicola@lampone ~]$ gcc x2.m -c
x2.m: In function ‘main’:
x2.m:11:3: warning: incompatible implicit declaration of built-in function
‘printf’ [enabled by default]
[nicola@lampone ~]$ cat x3.m
#include <objc/runtime.h>

@protocol A
- (void) test;
@end
[nicola@lampone ~]$ gcc x3.m -c
[nicola@lampone ~]$ gcc x2.o x3.o -lobjc
[nicola@lampone ~]$ ./a.out 
Protocol name is A
Method is <null selector>, (null)
[nicola@lampone ~]$

As you can see, in this case the protocol looks good if you check only the 
name, but it isn't, since the method is not there in the list of protocol 
methods!

Thanks


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug objc/48527] Incorrect list of methods in @protocol used across compilation units
  2011-04-09 10:46 [Bug objc/48527] New: Incorrect list of methods in @protocol used across compilation units nicola at gcc dot gnu.org
@ 2011-04-09 10:47 ` nicola at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-04-09 10:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48527

Nicola Pero <nicola at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.04.09 10:47:15
     Ever Confirmed|0                           |1

--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-04-09 10:47:15 UTC ---
The testcases/examples confirm it.

Thanks


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-09 10:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-09 10:46 [Bug objc/48527] New: Incorrect list of methods in @protocol used across compilation units nicola at gcc dot gnu.org
2011-04-09 10:47 ` [Bug objc/48527] " 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).