Commit 783bfe5e by Joseph Myers Committed by Joseph Myers

Rename attribute-related functions and productions in C parser.

The C2x attribute syntax, [[ ]], appears in different places in the
syntax from GNU __attribute__, and, where they can appear in the same
place in the syntax, they do not always appertain to the same entity.
(For example, in "int func(void) ATTRS;", GNU attributes appertain to
the declaration but C2x attributes appertain to the function type.)

Thus, the C parser needs to handle the two kinds of attributes
separately, with each place in the syntax accepting whatever kinds of
attributes are appropriate there and applying them to the relevant
entities.  This patch prepares for this by renaming parser functions
relating to attributes to make clear they are specifically about GNU
attributes and renaming syntax productions likewise to avoid confusing
with the C2x attributes syntax productions.

Where comments refer to attributes, this has only be changed where it
is clear that in the context they are referring specifically to the
gnu-attributes syntax.  There may be other places that also end up
changing to refer to gnu-attributes as part of the C2x attributes
implementation, if more detailed examination of those places shows
they are also specific to gnu-attributes.  (I do not expect code
dealing with semantics of attributes outside of the parser to need to
change; as for C++, it will be possible to use existing attributes
inside [[]] with the gnu:: form of the attribute name.)

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

	* c-parser.c (c_parser_attribute_any_word): Rename to
	c_parser_gnu_attribute_any_word.  All callers changed.
	(c_parser_attribute): Rename to c_parser_gnu_attribute.  All
	callers changed.
	(c_parser_attributes): Rename to c_parser_gnu_attributes.  All
	callers changed.
	(c_parser_declaration_or_fndef, c_parser_declspecs)
	(c_parser_enum_specifier, c_parser_struct_or_union_specifier)
	(c_parser_struct_declaration, c_parser_declarator)
	(c_parser_gnu_attribute, c_parser_compound_statement)
	(c_parser_label, c_parser_statement, c_parser_objc_method_decl)
	(c_parser_transaction_attributes): Add "gnu-" prefix to names of
	attribute-related syntax productions.

From-SVN: r276978
parent 490d1b4a
2019-10-15 Joseph Myers <joseph@codesourcery.com>
* c-parser.c (c_parser_attribute_any_word): Rename to
c_parser_gnu_attribute_any_word. All callers changed.
(c_parser_attribute): Rename to c_parser_gnu_attribute. All
callers changed.
(c_parser_attributes): Rename to c_parser_gnu_attributes. All
callers changed.
(c_parser_declaration_or_fndef, c_parser_declspecs)
(c_parser_enum_specifier, c_parser_struct_or_union_specifier)
(c_parser_struct_declaration, c_parser_declarator)
(c_parser_gnu_attribute, c_parser_compound_statement)
(c_parser_label, c_parser_statement, c_parser_objc_method_decl)
(c_parser_transaction_attributes): Add "gnu-" prefix to names of
attribute-related syntax productions.
2019-10-14 Richard Sandiford <richard.sandiford@arm.com> 2019-10-14 Richard Sandiford <richard.sandiford@arm.com>
* c-objc-common.c (useful_aka_type_p): Replace with... * c-objc-common.c (useful_aka_type_p): Replace with...
......
...@@ -1400,7 +1400,7 @@ static struct c_arg_info *c_parser_parms_list_declarator (c_parser *, tree, ...@@ -1400,7 +1400,7 @@ static struct c_arg_info *c_parser_parms_list_declarator (c_parser *, tree,
tree); tree);
static struct c_parm *c_parser_parameter_declaration (c_parser *, tree); static struct c_parm *c_parser_parameter_declaration (c_parser *, tree);
static tree c_parser_simple_asm_expr (c_parser *); static tree c_parser_simple_asm_expr (c_parser *);
static tree c_parser_attributes (c_parser *); static tree c_parser_gnu_attributes (c_parser *);
static struct c_expr c_parser_initializer (c_parser *); static struct c_expr c_parser_initializer (c_parser *);
static struct c_expr c_parser_braced_init (c_parser *, tree, bool, static struct c_expr c_parser_braced_init (c_parser *, tree, bool,
struct obstack *); struct obstack *);
...@@ -1714,8 +1714,8 @@ add_debug_begin_stmt (location_t loc) ...@@ -1714,8 +1714,8 @@ add_debug_begin_stmt (location_t loc)
init-declarator-list , init-declarator init-declarator-list , init-declarator
init-declarator: init-declarator:
declarator simple-asm-expr[opt] attributes[opt] declarator simple-asm-expr[opt] gnu-attributes[opt]
declarator simple-asm-expr[opt] attributes[opt] = initializer declarator simple-asm-expr[opt] gnu-attributes[opt] = initializer
GNU extensions: GNU extensions:
...@@ -1726,11 +1726,11 @@ add_debug_begin_stmt (location_t loc) ...@@ -1726,11 +1726,11 @@ add_debug_begin_stmt (location_t loc)
attribute ; attribute ;
Objective-C: Objective-C:
attributes objc-class-definition gnu-attributes objc-class-definition
attributes objc-category-definition gnu-attributes objc-category-definition
attributes objc-protocol-definition gnu-attributes objc-protocol-definition
The simple-asm-expr and attributes are GNU extensions. The simple-asm-expr and gnu-attributes are GNU extensions.
This function does not handle __extension__; that is handled in its This function does not handle __extension__; that is handled in its
callers. ??? Following the old parser, __extension__ may start callers. ??? Following the old parser, __extension__ may start
...@@ -2043,7 +2043,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, ...@@ -2043,7 +2043,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
asm_name = c_parser_simple_asm_expr (parser); asm_name = c_parser_simple_asm_expr (parser);
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
{ {
postfix_attrs = c_parser_attributes (parser); postfix_attrs = c_parser_gnu_attributes (parser);
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
{ {
/* This means there is an attribute specifier after /* This means there is an attribute specifier after
...@@ -2244,7 +2244,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, ...@@ -2244,7 +2244,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
} }
c_parser_consume_token (parser); c_parser_consume_token (parser);
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
all_prefix_attrs = chainon (c_parser_attributes (parser), all_prefix_attrs = chainon (c_parser_gnu_attributes (parser),
prefix_attrs); prefix_attrs);
else else
all_prefix_attrs = prefix_attrs; all_prefix_attrs = prefix_attrs;
...@@ -2544,7 +2544,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) ...@@ -2544,7 +2544,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser)
6.7, C11 6.7), adding them to SPECS (which may already include some). 6.7, C11 6.7), adding them to SPECS (which may already include some).
Storage class specifiers are accepted iff SCSPEC_OK; type Storage class specifiers are accepted iff SCSPEC_OK; type
specifiers are accepted iff TYPESPEC_OK; alignment specifiers are specifiers are accepted iff TYPESPEC_OK; alignment specifiers are
accepted iff ALIGNSPEC_OK; attributes are accepted at the start accepted iff ALIGNSPEC_OK; gnu-attributes are accepted at the start
iff START_ATTR_OK; __auto_type is accepted iff AUTO_TYPE_OK. iff START_ATTR_OK; __auto_type is accepted iff AUTO_TYPE_OK.
declaration-specifiers: declaration-specifiers:
...@@ -2613,7 +2613,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) ...@@ -2613,7 +2613,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser)
GNU extensions: GNU extensions:
declaration-specifiers: declaration-specifiers:
attributes declaration-specifiers[opt] gnu-attributes declaration-specifiers[opt]
type-qualifier: type-qualifier:
address-space address-space
...@@ -2906,7 +2906,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, ...@@ -2906,7 +2906,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
case RID_ATTRIBUTE: case RID_ATTRIBUTE:
if (!attrs_ok) if (!attrs_ok)
goto out; goto out;
attrs = c_parser_attributes (parser); attrs = c_parser_gnu_attributes (parser);
declspecs_add_attrs (loc, specs, attrs); declspecs_add_attrs (loc, specs, attrs);
break; break;
case RID_ALIGNAS: case RID_ALIGNAS:
...@@ -2939,12 +2939,14 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, ...@@ -2939,12 +2939,14 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
/* Parse an enum specifier (C90 6.5.2.2, C99 6.7.2.2, C11 6.7.2.2). /* Parse an enum specifier (C90 6.5.2.2, C99 6.7.2.2, C11 6.7.2.2).
enum-specifier: enum-specifier:
enum attributes[opt] identifier[opt] { enumerator-list } attributes[opt] enum gnu-attributes[opt] identifier[opt] { enumerator-list }
enum attributes[opt] identifier[opt] { enumerator-list , } attributes[opt] gnu-attributes[opt]
enum attributes[opt] identifier enum gnu-attributes[opt] identifier[opt] { enumerator-list , }
gnu-attributes[opt]
enum gnu-attributes[opt] identifier
The form with trailing comma is new in C99. The forms with The form with trailing comma is new in C99. The forms with
attributes are GNU extensions. In GNU C, we accept any expression gnu-attributes are GNU extensions. In GNU C, we accept any expression
without commas in the syntax (assignment expressions, not just without commas in the syntax (assignment expressions, not just
conditional expressions); assignment expressions will be diagnosed conditional expressions); assignment expressions will be diagnosed
as non-constant. as non-constant.
...@@ -2960,8 +2962,8 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, ...@@ -2960,8 +2962,8 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
GNU Extensions: GNU Extensions:
enumerator: enumerator:
enumeration-constant attributes[opt] enumeration-constant gnu-attributes[opt]
enumeration-constant attributes[opt] = constant-expression enumeration-constant gnu-attributes[opt] = constant-expression
*/ */
...@@ -2975,7 +2977,7 @@ c_parser_enum_specifier (c_parser *parser) ...@@ -2975,7 +2977,7 @@ c_parser_enum_specifier (c_parser *parser)
location_t ident_loc = UNKNOWN_LOCATION; /* Quiet warning. */ location_t ident_loc = UNKNOWN_LOCATION; /* Quiet warning. */
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ENUM)); gcc_assert (c_parser_next_token_is_keyword (parser, RID_ENUM));
c_parser_consume_token (parser); c_parser_consume_token (parser);
attrs = c_parser_attributes (parser); attrs = c_parser_gnu_attributes (parser);
enum_loc = c_parser_peek_token (parser)->location; enum_loc = c_parser_peek_token (parser)->location;
/* Set the location in case we create a decl now. */ /* Set the location in case we create a decl now. */
c_parser_set_source_position_from_token (c_parser_peek_token (parser)); c_parser_set_source_position_from_token (c_parser_peek_token (parser));
...@@ -3031,7 +3033,7 @@ c_parser_enum_specifier (c_parser *parser) ...@@ -3031,7 +3033,7 @@ c_parser_enum_specifier (c_parser *parser)
decl_loc = value_loc = token->location; decl_loc = value_loc = token->location;
c_parser_consume_token (parser); c_parser_consume_token (parser);
/* Parse any specified attributes. */ /* Parse any specified attributes. */
tree enum_attrs = c_parser_attributes (parser); tree enum_attrs = c_parser_gnu_attributes (parser);
if (c_parser_next_token_is (parser, CPP_EQ)) if (c_parser_next_token_is (parser, CPP_EQ))
{ {
c_parser_consume_token (parser); c_parser_consume_token (parser);
...@@ -3069,7 +3071,7 @@ c_parser_enum_specifier (c_parser *parser) ...@@ -3069,7 +3071,7 @@ c_parser_enum_specifier (c_parser *parser)
break; break;
} }
} }
postfix_attrs = c_parser_attributes (parser); postfix_attrs = c_parser_gnu_attributes (parser);
ret.spec = finish_enum (type, nreverse (values), ret.spec = finish_enum (type, nreverse (values),
chainon (attrs, postfix_attrs)); chainon (attrs, postfix_attrs));
ret.kind = ctsk_tagdef; ret.kind = ctsk_tagdef;
...@@ -3102,9 +3104,9 @@ c_parser_enum_specifier (c_parser *parser) ...@@ -3102,9 +3104,9 @@ c_parser_enum_specifier (c_parser *parser)
/* Parse a struct or union specifier (C90 6.5.2.1, C99 6.7.2.1, C11 6.7.2.1). /* Parse a struct or union specifier (C90 6.5.2.1, C99 6.7.2.1, C11 6.7.2.1).
struct-or-union-specifier: struct-or-union-specifier:
struct-or-union attributes[opt] identifier[opt] struct-or-union gnu-attributes[opt] identifier[opt]
{ struct-contents } attributes[opt] { struct-contents } gnu-attributes[opt]
struct-or-union attributes[opt] identifier struct-or-union gnu-attributes[opt] identifier
struct-contents: struct-contents:
struct-declaration-list struct-declaration-list
...@@ -3160,7 +3162,7 @@ c_parser_struct_or_union_specifier (c_parser *parser) ...@@ -3160,7 +3162,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
} }
struct_loc = c_parser_peek_token (parser)->location; struct_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser); c_parser_consume_token (parser);
attrs = c_parser_attributes (parser); attrs = c_parser_gnu_attributes (parser);
/* Set the location in case we create a decl now. */ /* Set the location in case we create a decl now. */
c_parser_set_source_position_from_token (c_parser_peek_token (parser)); c_parser_set_source_position_from_token (c_parser_peek_token (parser));
...@@ -3276,7 +3278,7 @@ c_parser_struct_or_union_specifier (c_parser *parser) ...@@ -3276,7 +3278,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
recovered already. Go on with the next field. */ recovered already. Go on with the next field. */
} }
} }
postfix_attrs = c_parser_attributes (parser); postfix_attrs = c_parser_gnu_attributes (parser);
ret.spec = finish_struct (struct_loc, type, nreverse (contents), ret.spec = finish_struct (struct_loc, type, nreverse (contents),
chainon (attrs, postfix_attrs), struct_info); chainon (attrs, postfix_attrs), struct_info);
ret.kind = ctsk_tagdef; ret.kind = ctsk_tagdef;
...@@ -3309,15 +3311,15 @@ c_parser_struct_or_union_specifier (c_parser *parser) ...@@ -3309,15 +3311,15 @@ c_parser_struct_or_union_specifier (c_parser *parser)
type-specifier specifier-qualifier-list[opt] type-specifier specifier-qualifier-list[opt]
type-qualifier specifier-qualifier-list[opt] type-qualifier specifier-qualifier-list[opt]
alignment-specifier specifier-qualifier-list[opt] alignment-specifier specifier-qualifier-list[opt]
attributes specifier-qualifier-list[opt] gnu-attributes specifier-qualifier-list[opt]
struct-declarator-list: struct-declarator-list:
struct-declarator struct-declarator
struct-declarator-list , attributes[opt] struct-declarator struct-declarator-list , gnu-attributes[opt] struct-declarator
struct-declarator: struct-declarator:
declarator attributes[opt] declarator gnu-attributes[opt]
declarator[opt] : constant-expression attributes[opt] declarator[opt] : constant-expression gnu-attributes[opt]
GNU extensions: GNU extensions:
...@@ -3326,7 +3328,7 @@ c_parser_struct_or_union_specifier (c_parser *parser) ...@@ -3326,7 +3328,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
specifier-qualifier-list specifier-qualifier-list
Unlike the ISO C syntax, semicolons are handled elsewhere. The use Unlike the ISO C syntax, semicolons are handled elsewhere. The use
of attributes where shown is a GNU extension. In GNU C, we accept of gnu-attributes where shown is a GNU extension. In GNU C, we accept
any expression without commas in the syntax (assignment any expression without commas in the syntax (assignment
expressions, not just conditional expressions); assignment expressions, not just conditional expressions); assignment
expressions will be diagnosed as non-constant. */ expressions will be diagnosed as non-constant. */
...@@ -3446,7 +3448,7 @@ c_parser_struct_declaration (c_parser *parser) ...@@ -3446,7 +3448,7 @@ c_parser_struct_declaration (c_parser *parser)
width = c_parser_expr_no_commas (parser, NULL).value; width = c_parser_expr_no_commas (parser, NULL).value;
} }
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
postfix_attrs = c_parser_attributes (parser); postfix_attrs = c_parser_gnu_attributes (parser);
d = grokfield (c_parser_peek_token (parser)->location, d = grokfield (c_parser_peek_token (parser)->location,
declarator, specs, width, &all_prefix_attrs); declarator, specs, width, &all_prefix_attrs);
decl_attributes (&d, chainon (postfix_attrs, decl_attributes (&d, chainon (postfix_attrs,
...@@ -3454,7 +3456,7 @@ c_parser_struct_declaration (c_parser *parser) ...@@ -3454,7 +3456,7 @@ c_parser_struct_declaration (c_parser *parser)
DECL_CHAIN (d) = decls; DECL_CHAIN (d) = decls;
decls = d; decls = d;
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
all_prefix_attrs = chainon (c_parser_attributes (parser), all_prefix_attrs = chainon (c_parser_gnu_attributes (parser),
prefix_attrs); prefix_attrs);
else else
all_prefix_attrs = prefix_attrs; all_prefix_attrs = prefix_attrs;
...@@ -3600,7 +3602,7 @@ c_parser_alignas_specifier (c_parser * parser) ...@@ -3600,7 +3602,7 @@ c_parser_alignas_specifier (c_parser * parser)
direct-declarator: direct-declarator:
identifier identifier
( attributes[opt] declarator ) ( gnu-attributes[opt] declarator )
direct-declarator array-declarator direct-declarator array-declarator
direct-declarator ( parameter-type-list ) direct-declarator ( parameter-type-list )
direct-declarator ( identifier-list[opt] ) direct-declarator ( identifier-list[opt] )
...@@ -3611,9 +3613,9 @@ c_parser_alignas_specifier (c_parser * parser) ...@@ -3611,9 +3613,9 @@ c_parser_alignas_specifier (c_parser * parser)
type-qualifier-list: type-qualifier-list:
type-qualifier type-qualifier
attributes gnu-attributes
type-qualifier-list type-qualifier type-qualifier-list type-qualifier
type-qualifier-list attributes type-qualifier-list gnu-attributes
array-declarator: array-declarator:
[ type-qualifier-list[opt] assignment-expression[opt] ] [ type-qualifier-list[opt] assignment-expression[opt] ]
...@@ -3630,8 +3632,8 @@ c_parser_alignas_specifier (c_parser * parser) ...@@ -3630,8 +3632,8 @@ c_parser_alignas_specifier (c_parser * parser)
parameter-list , parameter-declaration parameter-list , parameter-declaration
parameter-declaration: parameter-declaration:
declaration-specifiers declarator attributes[opt] declaration-specifiers declarator gnu-attributes[opt]
declaration-specifiers abstract-declarator[opt] attributes[opt] declaration-specifiers abstract-declarator[opt] gnu-attributes[opt]
identifier-list: identifier-list:
identifier identifier
...@@ -3642,7 +3644,7 @@ c_parser_alignas_specifier (c_parser * parser) ...@@ -3642,7 +3644,7 @@ c_parser_alignas_specifier (c_parser * parser)
pointer[opt] direct-abstract-declarator pointer[opt] direct-abstract-declarator
direct-abstract-declarator: direct-abstract-declarator:
( attributes[opt] abstract-declarator ) ( gnu-attributes[opt] abstract-declarator )
direct-abstract-declarator[opt] array-declarator direct-abstract-declarator[opt] array-declarator
direct-abstract-declarator[opt] ( parameter-type-list[opt] ) direct-abstract-declarator[opt] ( parameter-type-list[opt] )
...@@ -3660,7 +3662,7 @@ c_parser_alignas_specifier (c_parser * parser) ...@@ -3660,7 +3662,7 @@ c_parser_alignas_specifier (c_parser * parser)
parameter-list ; parameter-list ;
parameter-forward-declarations parameter-list ; parameter-forward-declarations parameter-list ;
The uses of attributes shown above are GNU extensions. The uses of gnu-attributes shown above are GNU extensions.
Some forms of array declarator are not included in C99 in the Some forms of array declarator are not included in C99 in the
syntax for abstract declarators; these are disallowed elsewhere. syntax for abstract declarators; these are disallowed elsewhere.
...@@ -3705,7 +3707,7 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind, ...@@ -3705,7 +3707,7 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
parenthesized declarator. In an abstract declarator or parameter parenthesized declarator. In an abstract declarator or parameter
declarator, they could start a parenthesized declarator or a declarator, they could start a parenthesized declarator or a
parameter list. To tell which, the open parenthesis and any parameter list. To tell which, the open parenthesis and any
following attributes must be read. If a declaration specifier following gnu-attributes must be read. If a declaration specifier
follows, then it is a parameter list; if the specifier is a follows, then it is a parameter list; if the specifier is a
typedef name, there might be an ambiguity about redeclaring it, typedef name, there might be an ambiguity about redeclaring it,
which is resolved in the direction of treating it as a typedef which is resolved in the direction of treating it as a typedef
...@@ -3720,12 +3722,12 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind, ...@@ -3720,12 +3722,12 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
parentheses. The proper resolution of this ambiguity needs parentheses. The proper resolution of this ambiguity needs
documenting. At present we follow an accident of the old documenting. At present we follow an accident of the old
parser's implementation, whereby the first parameter must have parser's implementation, whereby the first parameter must have
some declaration specifiers other than just attributes. Thus as some declaration specifiers other than just gnu-attributes. Thus as
a parameter declaration it is treated as a parenthesized a parameter declaration it is treated as a parenthesized
parameter named x, and as an abstract declarator it is parameter named x, and as an abstract declarator it is
rejected. rejected.
??? Also following the old parser, attributes inside an empty ??? Also following the old parser, gnu-attributes inside an empty
parameter list are ignored, making it a list not yielding a parameter list are ignored, making it a list not yielding a
prototype, rather than giving an error or making it have one prototype, rather than giving an error or making it have one
parameter with implicit type int. parameter with implicit type int.
...@@ -3764,7 +3766,7 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind, ...@@ -3764,7 +3766,7 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
tree attrs; tree attrs;
struct c_declarator *inner; struct c_declarator *inner;
c_parser_consume_token (parser); c_parser_consume_token (parser);
attrs = c_parser_attributes (parser); attrs = c_parser_gnu_attributes (parser);
if (kind != C_DTR_NORMAL if (kind != C_DTR_NORMAL
&& (c_parser_next_token_starts_declspecs (parser) && (c_parser_next_token_starts_declspecs (parser)
|| c_parser_next_token_is (parser, CPP_CLOSE_PAREN))) || c_parser_next_token_is (parser, CPP_CLOSE_PAREN)))
...@@ -3903,7 +3905,7 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present, ...@@ -3903,7 +3905,7 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
tree attrs; tree attrs;
struct c_arg_info *args; struct c_arg_info *args;
c_parser_consume_token (parser); c_parser_consume_token (parser);
attrs = c_parser_attributes (parser); attrs = c_parser_gnu_attributes (parser);
args = c_parser_parms_declarator (parser, id_present, attrs); args = c_parser_parms_declarator (parser, id_present, attrs);
if (args == NULL) if (args == NULL)
return NULL; return NULL;
...@@ -4051,7 +4053,7 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs, tree expr) ...@@ -4051,7 +4053,7 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs, tree expr)
tree new_attrs; tree new_attrs;
c_parser_consume_token (parser); c_parser_consume_token (parser);
mark_forward_parm_decls (); mark_forward_parm_decls ();
new_attrs = c_parser_attributes (parser); new_attrs = c_parser_gnu_attributes (parser);
return c_parser_parms_list_declarator (parser, new_attrs, expr); return c_parser_parms_list_declarator (parser, new_attrs, expr);
} }
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
...@@ -4162,7 +4164,7 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs) ...@@ -4162,7 +4164,7 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs)
return NULL; return NULL;
} }
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
postfix_attrs = c_parser_attributes (parser); postfix_attrs = c_parser_gnu_attributes (parser);
/* Generate a location for the parameter, ranging from the start of the /* Generate a location for the parameter, ranging from the start of the
initial token to the end of the final token. initial token to the end of the final token.
...@@ -4264,7 +4266,7 @@ c_parser_simple_asm_expr (c_parser *parser) ...@@ -4264,7 +4266,7 @@ c_parser_simple_asm_expr (c_parser *parser)
} }
static tree static tree
c_parser_attribute_any_word (c_parser *parser) c_parser_gnu_attribute_any_word (c_parser *parser)
{ {
tree attr_name = NULL_TREE; tree attr_name = NULL_TREE;
...@@ -4329,20 +4331,20 @@ c_parser_attribute_any_word (c_parser *parser) ...@@ -4329,20 +4331,20 @@ c_parser_attribute_any_word (c_parser *parser)
return attr_name; return attr_name;
} }
/* Parse (possibly empty) attributes. This is a GNU extension. /* Parse (possibly empty) gnu-attributes. This is a GNU extension.
attributes: gnu-attributes:
empty empty
attributes attribute gnu-attributes gnu-attribute
attribute: gnu-attribute:
__attribute__ ( ( attribute-list ) ) __attribute__ ( ( gnu-attribute-list ) )
attribute-list: gnu-attribute-list:
attrib gnu-attrib
attribute_list , attrib gnu-attribute_list , gnu-attrib
attrib: gnu-attrib:
empty empty
any-word any-word
any-word ( identifier ) any-word ( identifier )
...@@ -4361,7 +4363,7 @@ c_parser_attribute_any_word (c_parser *parser) ...@@ -4361,7 +4363,7 @@ c_parser_attribute_any_word (c_parser *parser)
commas with no attributes in between. */ commas with no attributes in between. */
static tree static tree
c_parser_attribute (c_parser *parser, tree attrs, c_parser_gnu_attribute (c_parser *parser, tree attrs,
bool expect_comma = false, bool empty_ok = true) bool expect_comma = false, bool empty_ok = true)
{ {
bool comma_first = c_parser_next_token_is (parser, CPP_COMMA); bool comma_first = c_parser_next_token_is (parser, CPP_COMMA);
...@@ -4377,7 +4379,7 @@ c_parser_attribute (c_parser *parser, tree attrs, ...@@ -4377,7 +4379,7 @@ c_parser_attribute (c_parser *parser, tree attrs,
return attrs; return attrs;
} }
tree attr_name = c_parser_attribute_any_word (parser); tree attr_name = c_parser_gnu_attribute_any_word (parser);
if (attr_name == NULL_TREE) if (attr_name == NULL_TREE)
return NULL_TREE; return NULL_TREE;
...@@ -4476,7 +4478,7 @@ c_parser_attribute (c_parser *parser, tree attrs, ...@@ -4476,7 +4478,7 @@ c_parser_attribute (c_parser *parser, tree attrs,
} }
static tree static tree
c_parser_attributes (c_parser *parser) c_parser_gnu_attributes (c_parser *parser)
{ {
tree attrs = NULL_TREE; tree attrs = NULL_TREE;
while (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) while (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
...@@ -4503,7 +4505,7 @@ c_parser_attributes (c_parser *parser) ...@@ -4503,7 +4505,7 @@ c_parser_attributes (c_parser *parser)
for (bool expect_comma = false; ; expect_comma = true) for (bool expect_comma = false; ; expect_comma = true)
{ {
/* Parse a single attribute. */ /* Parse a single attribute. */
tree attr = c_parser_attribute (parser, attrs, expect_comma); tree attr = c_parser_gnu_attribute (parser, attrs, expect_comma);
if (attr == error_mark_node) if (attr == error_mark_node)
return attrs; return attrs;
if (!attr) if (!attr)
...@@ -4974,8 +4976,8 @@ c_parser_initval (c_parser *parser, struct c_expr *after, ...@@ -4974,8 +4976,8 @@ c_parser_initval (c_parser *parser, struct c_expr *after,
GNU syntax also permits (not shown above) labels at the end of GNU syntax also permits (not shown above) labels at the end of
compound statements, which yield an error. We don't allow labels compound statements, which yield an error. We don't allow labels
on declarations; this might seem like a natural extension, but on declarations; this might seem like a natural extension, but
there would be a conflict between attributes on the label and there would be a conflict between gnu-attributes on the label and
prefix attributes on the declaration. ??? The syntax follows the prefix gnu-attributes on the declaration. ??? The syntax follows the
old parser in requiring something after label declarations. old parser in requiring something after label declarations.
Although they are erroneous if the labels declared aren't defined, Although they are erroneous if the labels declared aren't defined,
is it useful for the syntax to be this way? is it useful for the syntax to be this way?
...@@ -5209,7 +5211,7 @@ c_parser_all_labels (c_parser *parser) ...@@ -5209,7 +5211,7 @@ c_parser_all_labels (c_parser *parser)
/* Parse a label (C90 6.6.1, C99 6.8.1, C11 6.8.1). /* Parse a label (C90 6.6.1, C99 6.8.1, C11 6.8.1).
label: label:
identifier : attributes[opt] identifier : gnu-attributes[opt]
case constant-expression : case constant-expression :
default : default :
...@@ -5218,7 +5220,7 @@ c_parser_all_labels (c_parser *parser) ...@@ -5218,7 +5220,7 @@ c_parser_all_labels (c_parser *parser)
label: label:
case constant-expression ... constant-expression : case constant-expression ... constant-expression :
The use of attributes on labels is a GNU extension. The syntax in The use of gnu-attributes on labels is a GNU extension. The syntax in
GNU C accepts any expressions without commas, non-constant GNU C accepts any expressions without commas, non-constant
expressions being rejected later. */ expressions being rejected later. */
...@@ -5268,7 +5270,7 @@ c_parser_label (c_parser *parser) ...@@ -5268,7 +5270,7 @@ c_parser_label (c_parser *parser)
c_parser_consume_token (parser); c_parser_consume_token (parser);
gcc_assert (c_parser_next_token_is (parser, CPP_COLON)); gcc_assert (c_parser_next_token_is (parser, CPP_COLON));
c_parser_consume_token (parser); c_parser_consume_token (parser);
attrs = c_parser_attributes (parser); attrs = c_parser_gnu_attributes (parser);
tlab = define_label (loc2, name); tlab = define_label (loc2, name);
if (tlab) if (tlab)
{ {
...@@ -5287,7 +5289,7 @@ c_parser_label (c_parser *parser) ...@@ -5287,7 +5289,7 @@ c_parser_label (c_parser *parser)
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
{ {
location_t loc = c_parser_peek_token (parser)->location; location_t loc = c_parser_peek_token (parser)->location;
tree attrs = c_parser_attributes (parser); tree attrs = c_parser_gnu_attributes (parser);
if (attribute_fallthrough_p (attrs)) if (attribute_fallthrough_p (attrs))
{ {
if (c_parser_next_token_is (parser, CPP_SEMICOLON)) if (c_parser_next_token_is (parser, CPP_SEMICOLON))
...@@ -5359,7 +5361,7 @@ c_parser_label (c_parser *parser) ...@@ -5359,7 +5361,7 @@ c_parser_label (c_parser *parser)
goto * expression ; goto * expression ;
expression-statement: expression-statement:
attributes ; gnu-attributes ;
Objective-C: Objective-C:
...@@ -5601,7 +5603,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, ...@@ -5601,7 +5603,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p,
case RID_ATTRIBUTE: case RID_ATTRIBUTE:
{ {
/* Allow '__attribute__((fallthrough));'. */ /* Allow '__attribute__((fallthrough));'. */
tree attrs = c_parser_attributes (parser); tree attrs = c_parser_gnu_attributes (parser);
if (attribute_fallthrough_p (attrs)) if (attribute_fallthrough_p (attrs))
{ {
if (c_parser_next_token_is (parser, CPP_SEMICOLON)) if (c_parser_next_token_is (parser, CPP_SEMICOLON))
...@@ -7703,7 +7705,7 @@ c_parser_has_attribute_expression (c_parser *parser) ...@@ -7703,7 +7705,7 @@ c_parser_has_attribute_expression (c_parser *parser)
location_t atloc = c_parser_peek_token (parser)->location; location_t atloc = c_parser_peek_token (parser)->location;
/* Parse a single attribute. Require no leading comma and do not /* Parse a single attribute. Require no leading comma and do not
allow empty attributes. */ allow empty attributes. */
tree attr = c_parser_attribute (parser, NULL_TREE, false, false); tree attr = c_parser_gnu_attribute (parser, NULL_TREE, false, false);
parser->lex_untranslated_string = false; parser->lex_untranslated_string = false;
...@@ -10495,7 +10497,7 @@ c_parser_objc_maybe_method_attributes (c_parser* parser, tree* attributes) ...@@ -10495,7 +10497,7 @@ c_parser_objc_maybe_method_attributes (c_parser* parser, tree* attributes)
} }
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
*attributes = c_parser_attributes (parser); *attributes = c_parser_gnu_attributes (parser);
/* If there were no attributes here, just report any earlier error. */ /* If there were no attributes here, just report any earlier error. */
if (*attributes == NULL_TREE || bad) if (*attributes == NULL_TREE || bad)
...@@ -10520,7 +10522,7 @@ c_parser_objc_maybe_method_attributes (c_parser* parser, tree* attributes) ...@@ -10520,7 +10522,7 @@ c_parser_objc_maybe_method_attributes (c_parser* parser, tree* attributes)
objc-selector objc-selector
( objc-type-name ) objc-keyword-selector objc-optparmlist ( objc-type-name ) objc-keyword-selector objc-optparmlist
objc-keyword-selector objc-optparmlist objc-keyword-selector objc-optparmlist
attributes gnu-attributes
objc-keyword-selector: objc-keyword-selector:
objc-keyword-decl objc-keyword-decl
...@@ -10585,7 +10587,7 @@ c_parser_objc_method_decl (c_parser *parser, bool is_class_method, ...@@ -10585,7 +10587,7 @@ c_parser_objc_method_decl (c_parser *parser, bool is_class_method,
} }
/* New ObjC allows attributes on method parameters. */ /* New ObjC allows attributes on method parameters. */
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
param_attr = c_parser_attributes (parser); param_attr = c_parser_gnu_attributes (parser);
if (c_parser_next_token_is_not (parser, CPP_NAME)) if (c_parser_next_token_is_not (parser, CPP_NAME))
{ {
c_parser_error (parser, "expected identifier"); c_parser_error (parser, "expected identifier");
...@@ -20559,7 +20561,7 @@ c_parser_omp_threadprivate (c_parser *parser) ...@@ -20559,7 +20561,7 @@ c_parser_omp_threadprivate (c_parser *parser)
/* Parse a transaction attribute (GCC Extension). /* Parse a transaction attribute (GCC Extension).
transaction-attribute: transaction-attribute:
attributes gnu-attributes
[ [ any-word ] ] [ [ any-word ] ]
The transactional memory language description is written for C++, The transactional memory language description is written for C++,
...@@ -20572,7 +20574,7 @@ c_parser_transaction_attributes (c_parser *parser) ...@@ -20572,7 +20574,7 @@ c_parser_transaction_attributes (c_parser *parser)
tree attr_name, attr = NULL; tree attr_name, attr = NULL;
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
return c_parser_attributes (parser); return c_parser_gnu_attributes (parser);
if (!c_parser_next_token_is (parser, CPP_OPEN_SQUARE)) if (!c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
return NULL_TREE; return NULL_TREE;
...@@ -20580,7 +20582,7 @@ c_parser_transaction_attributes (c_parser *parser) ...@@ -20580,7 +20582,7 @@ c_parser_transaction_attributes (c_parser *parser)
if (!c_parser_require (parser, CPP_OPEN_SQUARE, "expected %<[%>")) if (!c_parser_require (parser, CPP_OPEN_SQUARE, "expected %<[%>"))
goto error1; goto error1;
attr_name = c_parser_attribute_any_word (parser); attr_name = c_parser_gnu_attribute_any_word (parser);
if (attr_name) if (attr_name)
{ {
c_parser_consume_token (parser); c_parser_consume_token (parser);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment