Commit 309c23f7 by Richard Stallman

(attrib): Handle string args as expressions,

merging the two rules.  `mode' attribute now takes a string arg.
Delete the rule for an identifier as arg.

From-SVN: r6913
parent 423b04b0
...@@ -1062,31 +1062,27 @@ attribute_list ...@@ -1062,31 +1062,27 @@ attribute_list
; ;
attrib attrib
: IDENTIFIER : identifier
{ if (strcmp (IDENTIFIER_POINTER ($1), "packed") { if (strcmp (IDENTIFIER_POINTER ($1), "packed")
&& strcmp (IDENTIFIER_POINTER ($1), "noreturn")) && strcmp (IDENTIFIER_POINTER ($1), "noreturn"))
warning ("`%s' attribute directive ignored", warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1)); IDENTIFIER_POINTER ($1));
$$ = $1; } $$ = $1; }
| TYPE_QUAL | TYPE_QUAL
| IDENTIFIER '(' IDENTIFIER ')' | identifier '(' expr_no_commas ')'
{ /* If not "mode (m)" or "aligned", then issue warning. { /* If not aligned(n) or section(name), then issue warning */
If "aligned", this will later produce an error in decl_attributes if (strcmp (IDENTIFIER_POINTER ($1), "section") == 0
since an identifier is not a valid constant, but we want to give || strcmp (IDENTIFIER_POINTER ($1), "mode") == 0)
an error instead of a warning when the attribute name is
recognized but has an improper argument. */
if (strcmp (IDENTIFIER_POINTER ($1), "mode") != 0
&& strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0)
{ {
warning ("`%s' attribute directive ignored", if (TREE_CODE ($3) != STRING_CST)
IDENTIFIER_POINTER ($1)); {
$$ = $1; error ("invalid argument in `%s' attribute",
IDENTIFIER_POINTER ($1));
$$ = $1;
}
$$ = tree_cons ($1, $3, NULL_TREE);
} }
else else if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0)
$$ = tree_cons ($1, $3, NULL_TREE); }
| IDENTIFIER '(' expr_no_commas ')'
{ /* if not "aligned(n)", then issue warning */
if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0)
{ {
warning ("`%s' attribute directive ignored", warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1)); IDENTIFIER_POINTER ($1));
...@@ -1094,7 +1090,7 @@ attrib ...@@ -1094,7 +1090,7 @@ attrib
} }
else else
$$ = tree_cons ($1, $3, NULL_TREE); } $$ = tree_cons ($1, $3, NULL_TREE); }
| IDENTIFIER '(' IDENTIFIER ',' expr_no_commas ',' expr_no_commas ')' | identifier '(' IDENTIFIER ',' expr_no_commas ',' expr_no_commas ')'
{ /* if not "format(...)", then issue warning */ { /* if not "format(...)", then issue warning */
if (strcmp (IDENTIFIER_POINTER ($1), "format") != 0) if (strcmp (IDENTIFIER_POINTER ($1), "format") != 0)
{ {
...@@ -1108,16 +1104,6 @@ attrib ...@@ -1108,16 +1104,6 @@ attrib
tree_cons ($5, $7, NULL_TREE), tree_cons ($5, $7, NULL_TREE),
NULL_TREE), NULL_TREE),
NULL_TREE); } NULL_TREE); }
| IDENTIFIER '(' STRING ')'
{ /* If not "section (name)", then issue warning. */
if (strcmp (IDENTIFIER_POINTER ($1), "section") != 0)
{
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1));
$$ = $1;
}
else
$$ = tree_cons ($1, $3, NULL_TREE); }
; ;
/* Initializers. `init' is the entry point. */ /* Initializers. `init' is the entry point. */
......
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