public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/94637] New: @selector() broken for selectors containing repeated colons
@ 2020-04-17 12:50 rfm at gnu dot org
2020-04-17 12:52 ` [Bug objc/94637] " rfm at gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: rfm at gnu dot org @ 2020-04-17 12:50 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
@ 2020-04-17 12:52 ` rfm at gnu dot org
2020-04-17 14:17 ` egallager at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rfm at gnu dot org @ 2020-04-17 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
--- Comment #1 from rfm at gnu dot org ---
*** Bug 94638 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
2020-04-17 12:52 ` [Bug objc/94637] " rfm at gnu dot org
@ 2020-04-17 14:17 ` egallager at gcc dot gnu.org
2020-04-17 16:35 ` [Bug objc/94637] [10 Regression] " pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2020-04-17 14:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org,
| |iains at gcc dot gnu.org,
| |mikestump at comcast dot net
--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
cc-ing Objective C maintainers
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] [10 Regression] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
2020-04-17 12:52 ` [Bug objc/94637] " rfm at gnu dot org
2020-04-17 14:17 ` egallager at gcc dot gnu.org
@ 2020-04-17 16:35 ` pinskia at gcc dot gnu.org
2020-04-17 16:36 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-17 16:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Keywords| |rejects-valid
Target Milestone|--- |10.0
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-04-17
Summary|@selector() broken for |[10 Regression] @selector()
|selectors containing |broken for selectors
|repeated colons |containing repeated colons
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely caused by g:93313b94fe18f3c3de4f24f5bb3fafb4639f1c7e .
That is CPP_SCOPE should be treated as two CPP_COLON tokens while parsing
@selector like was done for asm parsing.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] [10 Regression] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
` (2 preceding siblings ...)
2020-04-17 16:35 ` [Bug objc/94637] [10 Regression] " pinskia at gcc dot gnu.org
@ 2020-04-17 16:36 ` pinskia at gcc dot gnu.org
2020-04-17 17:48 ` law at redhat dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-17 16:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The change needs to happen inside c_parser_objc_selector_arg.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] [10 Regression] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
` (3 preceding siblings ...)
2020-04-17 16:36 ` pinskia at gcc dot gnu.org
@ 2020-04-17 17:48 ` law at redhat dot com
2020-04-17 18:01 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: law at redhat dot com @ 2020-04-17 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
Jeffrey A. Law <law at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at redhat dot com
Priority|P3 |P4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] [10 Regression] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
` (4 preceding siblings ...)
2020-04-17 17:48 ` law at redhat dot com
@ 2020-04-17 18:01 ` jakub at gcc dot gnu.org
2020-04-19 10:14 ` cvs-commit at gcc dot gnu.org
2020-04-19 21:36 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-17 18:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So like:
--- gcc/c/c-parser.c.jj 2020-04-17 16:59:28.727193750 +0200
+++ gcc/c/c-parser.c 2020-04-17 20:00:59.816403446 +0200
@@ -11782,15 +11782,28 @@ c_parser_objc_selector_arg (c_parser *pa
{
tree sel = c_parser_objc_selector (parser);
tree list = NULL_TREE;
- if (sel && c_parser_next_token_is_not (parser, CPP_COLON))
+ if (sel
+ && c_parser_next_token_is_not (parser, CPP_COLON)
+ && c_parser_next_token_is_not (parser, CPP_SCOPE))
return sel;
while (true)
{
- if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
- return list;
- list = chainon (list, build_tree_list (sel, NULL_TREE));
+ if (c_parser_next_token_is (parser, CPP_SCOPE))
+ {
+ c_parser_consume_token (parser);
+ list = chainon (list, build_tree_list (sel, NULL_TREE));
+ list = chainon (list, build_tree_list (NULL_TREE, NULL_TREE);
+ }
+ else
+ {
+ if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
+ return list;
+ list = chainon (list, build_tree_list (sel, NULL_TREE));
+ }
sel = c_parser_objc_selector (parser);
- if (!sel && c_parser_next_token_is_not (parser, CPP_COLON))
+ if (!sel
+ && c_parser_next_token_is_not (parser, CPP_COLON)
+ && c_parser_next_token_is_not (parser, CPP_SCOPE))
break;
}
return list;
? Completely untested, will try later.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] [10 Regression] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
` (5 preceding siblings ...)
2020-04-17 18:01 ` jakub at gcc dot gnu.org
@ 2020-04-19 10:14 ` cvs-commit at gcc dot gnu.org
2020-04-19 21:36 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-19 10:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:e1113ffbd619d0568fb3b37e9660d9e0ae7862f5
commit r10-7794-ge1113ffbd619d0568fb3b37e9660d9e0ae7862f5
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sun Apr 19 12:13:33 2020 +0200
c, objc: Fix up c_parser_objc_selector_arg after CPP_SCOPE changes
[PR94637]
Similarly to inline asm, :: (or any other number of consecutive colons) can
appear in ObjC @selector argument and with the introduction of CPP_SCOPE
into the C FE, we need to trat CPP_SCOPE as two CPP_COLON tokens.
The C++ FE does that already that way.
2020-04-19 Jakub Jelinek <jakub@redhat.com>
PR objc/94637
* c-parser.c (c_parser_objc_selector_arg): Handle CPP_SCOPE like
two CPP_COLON tokens.
* objc.dg/pr94637.m: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug objc/94637] [10 Regression] @selector() broken for selectors containing repeated colons
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
` (6 preceding siblings ...)
2020-04-19 10:14 ` cvs-commit at gcc dot gnu.org
@ 2020-04-19 21:36 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-19 21:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94637
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-04-19 21:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17 12:50 [Bug objc/94637] New: @selector() broken for selectors containing repeated colons rfm at gnu dot org
2020-04-17 12:52 ` [Bug objc/94637] " rfm at gnu dot org
2020-04-17 14:17 ` egallager at gcc dot gnu.org
2020-04-17 16:35 ` [Bug objc/94637] [10 Regression] " pinskia at gcc dot gnu.org
2020-04-17 16:36 ` pinskia at gcc dot gnu.org
2020-04-17 17:48 ` law at redhat dot com
2020-04-17 18:01 ` jakub at gcc dot gnu.org
2020-04-19 10:14 ` cvs-commit at gcc dot gnu.org
2020-04-19 21:36 ` jakub 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).