From e344ea07e4024316e1bc01f18bf7f187ad3aef89 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Fri, 30 Oct 2020 19:24:07 +0000 Subject: [PATCH] Objective-C++ : Address a FIXME. We can avoid the spurious additional complaint about a closing ')' by short-circuiting the test in the case we know there's a syntax error already reported. gcc/cp/ChangeLog: * parser.c (cp_parser_objc_at_property_declaration): Use any exisiting syntax error to suppress complaints about a missing closing parenthesis in parsing property attributes. gcc/testsuite/ChangeLog: * obj-c++.dg/property/at-property-1.mm: Adjust test after fixing spurious error output. --- gcc/cp/parser.c | 13 ++++--------- gcc/testsuite/obj-c++.dg/property/at-property-1.mm | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bd8c241..dd8c4b5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -33884,16 +33884,17 @@ cp_parser_objc_at_property_declaration (cp_parser *parser) /* Eat the '('. */ matching_parens parens; parens.consume_open (parser); + bool syntax_error = false; while (true) { - bool syntax_error = false; cp_token *token = cp_lexer_peek_token (parser->lexer); enum rid keyword; if (token->type != CPP_NAME) { cp_parser_error (parser, "expected identifier"); + syntax_error = true; break; } keyword = C_RID_CODE (token->u.value); @@ -33967,17 +33968,11 @@ cp_parser_objc_at_property_declaration (cp_parser *parser) break; } - /* FIXME: "@property (setter, assign);" will generate a spurious - "error: expected ‘)’ before ‘,’ token". This is because - cp_parser_require, unlike the C counterpart, will produce an - error even if we are in error recovery. */ - if (!parens.require_close (parser)) - { - cp_parser_skip_to_closing_parenthesis (parser, + if (syntax_error || !parens.require_close (parser)) + cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, /*or_comma=*/false, /*consume_paren=*/true); - } } /* ... and the property declaration(s). */ diff --git a/gcc/testsuite/obj-c++.dg/property/at-property-1.mm b/gcc/testsuite/obj-c++.dg/property/at-property-1.mm index 7cf650f..6a90471 100644 --- a/gcc/testsuite/obj-c++.dg/property/at-property-1.mm +++ b/gcc/testsuite/obj-c++.dg/property/at-property-1.mm @@ -16,5 +16,4 @@ @property (xxx) int g; /* { dg-error "unknown property attribute" } */ @property (readonly,xxx) int h; /* { dg-error "unknown property attribute" } */ @property ( int i; /* { dg-error "expected identifier" } */ - /* { dg-error "expected ... " "" { target *-*-* } .-1 } */ @end -- 2.7.4