From: Jakub Jelinek Date: Sun, 19 Apr 2020 10:13:33 +0000 (+0200) Subject: c, objc: Fix up c_parser_objc_selector_arg after CPP_SCOPE changes [PR94637] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e1113ffbd619d0568fb3b37e9660d9e0ae7862f5;p=gcc.git 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 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. --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b6af6761788..83d1ccc8edc 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2020-04-19 Jakub Jelinek + + PR objc/94637 + * c-parser.c (c_parser_objc_selector_arg): Handle CPP_SCOPE like + two CPP_COLON tokens. + 2020-04-17 Jakub Jelinek PR other/94629 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 4e90d55f30f..ae354e6af66 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -11782,15 +11782,28 @@ c_parser_objc_selector_arg (c_parser *parser) { 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fb1a1539d6a..9f8ae6ccccb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-19 Jakub Jelinek + + PR objc/94637 + * objc.dg/pr94637.m: New test. + 2020-04-18 Iain Buclaw * lib/gdc-utils.exp (gdc-convert-test): Add dg-skip-if for tests that diff --git a/gcc/testsuite/objc.dg/pr94637.m b/gcc/testsuite/objc.dg/pr94637.m new file mode 100644 index 00000000000..10a0ea8307b --- /dev/null +++ b/gcc/testsuite/objc.dg/pr94637.m @@ -0,0 +1,10 @@ +/* PR objc/94637 */ +/* { dg-do compile } */ + +#include + +SEL +foo () +{ + return @selector(example::); +}