https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
Bug ID: 94637
Summary: @selector() broken for selectors containing repeated
colons
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: objc
Assignee: unassigned at gcc dot gnu.org
Reporter: rfm at gnu dot org
Target Milestone: ---
The compiler fails to compile legal Objective-C programs which use the
@selector() syntax to send message to objects, if those messages have multiple
parameters and the method does not describe each one.
eg. when given @selector(styleoffsets::::::) the compiler errors with the
message
error: expected ‘)’ before ‘::’ token
Within @selector() each colon marks the position at which an argument would be
inserted in a method invocation (when a message is sent to an object). It is
therefore not legal for the compiler to consider a pair of colons to be a token
in this context.
In the above example, the method declaration looks like this:
- (void) styleoffsets: (float*)l : (float*)r : (float*)t : (float*)b
: (unsigned int)style;
While imo it would be better coding style to describe parameters as part of the
method name, it's certainly correct/legal objective-c to have multiple
parameters each preceded only by a colon.
A trivial program to demonstrate the bug would be
#include <stdio.h>
#include <objc/objc.h>
int main()
{
SEL s = @selector(example::);
printf("%s\n", sel_getName(s));
return 0;
}
This program, if built with the command 'gcc program.m -lobjc' should produce
an a.out which just prints the selector name.