aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1994-03-28 01:27:48 +0000
committerRichard Stallman <rms@gnu.org>1994-03-28 01:27:48 +0000
commit309c23f7ddea7a9e2d26cf66c42bfc3731f17da9 (patch)
treee6a32df38bf1e0fa2294fe9dc790dc3e90f69a7c
parent423b04b06f9c845e907bd3ce0915c065b9e27cdb (diff)
downloadgcc-309c23f7ddea7a9e2d26cf66c42bfc3731f17da9.zip
gcc-309c23f7ddea7a9e2d26cf66c42bfc3731f17da9.tar.gz
gcc-309c23f7ddea7a9e2d26cf66c42bfc3731f17da9.tar.bz2
(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
-rw-r--r--gcc/c-parse.in42
1 files changed, 14 insertions, 28 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 36cfa2a..57530d0 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -1062,31 +1062,27 @@ attribute_list
;
attrib
- : IDENTIFIER
+ : identifier
{ if (strcmp (IDENTIFIER_POINTER ($1), "packed")
&& strcmp (IDENTIFIER_POINTER ($1), "noreturn"))
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1));
$$ = $1; }
| TYPE_QUAL
- | IDENTIFIER '(' IDENTIFIER ')'
- { /* If not "mode (m)" or "aligned", then issue warning.
- If "aligned", this will later produce an error in decl_attributes
- since an identifier is not a valid constant, but we want to give
- 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)
+ | identifier '(' expr_no_commas ')'
+ { /* If not aligned(n) or section(name), then issue warning */
+ if (strcmp (IDENTIFIER_POINTER ($1), "section") == 0
+ || strcmp (IDENTIFIER_POINTER ($1), "mode") == 0)
{
- warning ("`%s' attribute directive ignored",
- IDENTIFIER_POINTER ($1));
- $$ = $1;
+ if (TREE_CODE ($3) != STRING_CST)
+ {
+ error ("invalid argument in `%s' attribute",
+ IDENTIFIER_POINTER ($1));
+ $$ = $1;
+ }
+ $$ = tree_cons ($1, $3, NULL_TREE);
}
- else
- $$ = tree_cons ($1, $3, NULL_TREE); }
- | IDENTIFIER '(' expr_no_commas ')'
- { /* if not "aligned(n)", then issue warning */
- if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0)
+ else if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0)
{
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1));
@@ -1094,7 +1090,7 @@ attrib
}
else
$$ = 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 (strcmp (IDENTIFIER_POINTER ($1), "format") != 0)
{
@@ -1108,16 +1104,6 @@ attrib
tree_cons ($5, $7, 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. */