aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-12-26 11:16:01 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-12-26 11:16:01 +0100
commit7cd268ad6a6f71877744539d17ed53e752774bfa (patch)
tree3a55ec188547087fe3db9a81420da7db66097d60 /gcc/cp/parser.c
parentae2bb2a6434d3177b94f78ac707f606ee65f0360 (diff)
downloadgcc-7cd268ad6a6f71877744539d17ed53e752774bfa.zip
gcc-7cd268ad6a6f71877744539d17ed53e752774bfa.tar.gz
gcc-7cd268ad6a6f71877744539d17ed53e752774bfa.tar.bz2
re PR c++/92438 (Function declaration parsed incorrectly with `-std=c++1z`)
PR c++/92438 * parser.c (cp_parser_constructor_declarator_p): If open paren is followed by RID_ATTRIBUTE, skip over the attribute tokens and try to parse type specifier. * g++.dg/ext/attrib61.C: New test. From-SVN: r279736
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c3c968d..c66ef34 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -28493,7 +28493,15 @@ cp_parser_constructor_declarator_p (cp_parser *parser, cp_parser_flags flags,
/* A parameter declaration begins with a decl-specifier,
which is either the "attribute" keyword, a storage class
specifier, or (usually) a type-specifier. */
- && !cp_lexer_next_token_is_decl_specifier_keyword (parser->lexer)
+ && (!cp_lexer_next_token_is_decl_specifier_keyword (parser->lexer)
+ /* GNU attributes can actually appear both at the start of
+ a parameter and parenthesized declarator.
+ S (__attribute__((unused)) int);
+ is a constructor, but
+ S (__attribute__((unused)) foo) (int);
+ is a function declaration. */
+ || (cp_parser_allow_gnu_extensions_p (parser)
+ && cp_next_tokens_can_be_gnu_attribute_p (parser)))
/* A parameter declaration can also begin with [[attribute]]. */
&& !cp_next_tokens_can_be_std_attribute_p (parser))
{
@@ -28501,6 +28509,13 @@ cp_parser_constructor_declarator_p (cp_parser *parser, cp_parser_flags flags,
tree pushed_scope = NULL_TREE;
unsigned saved_num_template_parameter_lists;
+ if (cp_next_tokens_can_be_gnu_attribute_p (parser))
+ {
+ unsigned int n = cp_parser_skip_gnu_attributes_opt (parser, 1);
+ while (--n)
+ cp_lexer_consume_token (parser->lexer);
+ }
+
/* Names appearing in the type-specifier should be looked up
in the scope of the class. */
if (current_class_type)