aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorMichel Morin <mimomorin@gmail.com>2021-09-22 08:04:31 +0900
committerJason Merrill <jason@redhat.com>2021-09-23 16:25:45 -0400
commite5c0492b7f42ccc093f9f4385bbbc4b39dc5ffcb (patch)
treebea8a19259600ace443a764b3db1d0c075efab59 /gcc/cp/parser.c
parenteb9f099c3df2b1b4c5fb0fa25cfdfa3cb5fc817e (diff)
downloadgcc-e5c0492b7f42ccc093f9f4385bbbc4b39dc5ffcb.zip
gcc-e5c0492b7f42ccc093f9f4385bbbc4b39dc5ffcb.tar.gz
gcc-e5c0492b7f42ccc093f9f4385bbbc4b39dc5ffcb.tar.bz2
c++: adjust the handling of RID_ATTRIBUTE.
gcc/cp/ChangeLog: * parser.c (cp_keyword_starts_decl_specifier_p): Do not handle RID_ATTRIBUTE. (cp_parser_constructor_declarator_p): Remove now-redundant checks. (cp_parser_lambda_declarator_opt): Likewise.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1d1543d..8430445 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1062,7 +1062,6 @@ cp_keyword_starts_decl_specifier_p (enum rid keyword)
case RID_TYPEDEF:
case RID_INLINE:
/* GNU extensions. */
- case RID_ATTRIBUTE:
case RID_TYPEOF:
/* C++11 extensions. */
case RID_DECLTYPE:
@@ -11466,8 +11465,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
/* In the decl-specifier-seq of the lambda-declarator, each
decl-specifier shall either be mutable or constexpr. */
int declares_class_or_enum;
- if (cp_lexer_next_token_is_decl_specifier_keyword (parser->lexer)
- && !cp_next_tokens_can_be_gnu_attribute_p (parser))
+ if (cp_lexer_next_token_is_decl_specifier_keyword (parser->lexer))
cp_parser_decl_specifier_seq (parser,
CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR,
&lambda_specs, &declares_class_or_enum);
@@ -30844,23 +30842,22 @@ 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)
- /* 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_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. [[attribute]] can appear in the
+ first form too, but not in the second form. */
&& !cp_next_tokens_can_be_std_attribute_p (parser))
{
tree type;
tree pushed_scope = NULL_TREE;
unsigned saved_num_template_parameter_lists;
- if (cp_next_tokens_can_be_gnu_attribute_p (parser))
+ if (cp_parser_allow_gnu_extensions_p (parser)
+ && cp_next_tokens_can_be_gnu_attribute_p (parser))
{
unsigned int n = cp_parser_skip_gnu_attributes_opt (parser, 1);
while (--n)