Commit 660b43c8 by Richard Kenner

Rewrite attribute parsing; update the expected conflicts and state

numbers.

From-SVN: r7252
parent bad1b4ba
...@@ -27,22 +27,23 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -27,22 +27,23 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
written by AT&T, but I have never seen it. */ written by AT&T, but I have never seen it. */
ifobjc ifobjc
%expect 20 %expect 22
end ifobjc end ifobjc
ifc ifc
%expect 8 %expect 10
/* These are the 8 conflicts you should get in parse.output; /* These are the 10 conflicts you should get in parse.output;
the state numbers may vary if minor changes in the grammar are made. the state numbers may vary if minor changes in the grammar are made.
State 41 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 41 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 92 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 97 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 99 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 104 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 103 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 108 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 119 contains 1 shift/reduce conflict. (See comment at component_decl.) State 124 contains 1 shift/reduce conflict. (See comment at component_decl.)
State 183 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 191 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 193 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 204 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 199 contains 1 shift/reduce conflict. (Two ways to recover from error.) State 210 contains 1 shift/reduce conflict. (Two ways to recover from error.)
State 449 contains 2 shift/reduce conflicts. (Four ways to parse this.)
*/ */
end ifc end ifc
...@@ -178,7 +179,8 @@ void yyerror (); ...@@ -178,7 +179,8 @@ void yyerror ();
%type <ttype> initdecls notype_initdecls initdcl notype_initdcl %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
%type <ttype> init maybeasm %type <ttype> init maybeasm
%type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
%type <ttype> maybe_attribute attribute_list attrib %type <ttype> maybe_attribute attributes attribute attribute_list attrib
%type <ttype> any_word
%type <ttype> compstmt %type <ttype> compstmt
...@@ -1048,63 +1050,55 @@ notype_initdcl: ...@@ -1048,63 +1050,55 @@ notype_initdcl:
/* the * rules are dummies to accept the Apollo extended syntax /* the * rules are dummies to accept the Apollo extended syntax
so that the header files compile. */ so that the header files compile. */
maybe_attribute: maybe_attribute:
/* empty */
{ $$ = NULL_TREE; }
| attributes
{ $$ = $1; }
;
attributes:
attribute
{ $$ = $1; }
| attributes attribute
{ $$ = chainon ($1, $2); }
;
attribute:
ATTRIBUTE '(' '(' attribute_list ')' ')'
{ $$ = $4; }
;
attribute_list:
attrib
{ $$ = build_tree_list (NULL_TREE, $1); }
| attribute_list ',' attrib
{ $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
;
attrib:
/* empty */ /* empty */
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| maybe_attribute ATTRIBUTE '(' '(' attribute_list ')' ')' | any_word
{ $$ = chainon ($5, $1); } { $$ = $1; }
; | any_word '(' IDENTIFIER ')'
{ $$ = tree_cons ($1, NULL_TREE,
attribute_list build_tree_list (NULL_TREE, $3)); }
: attrib | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE); } { $$ = tree_cons ($1, NULL_TREE,
| attribute_list ',' attrib tree_cons (NULL_TREE, $3, $5)); }
{ $$ = tree_cons (NULL_TREE, $3, $1); } | any_word '(' nonnull_exprlist ')'
; { $$ = tree_cons ($1, NULL_TREE, $3); }
;
attrib
: identifier /* This still leaves out most reserved keywords,
{ if (strcmp (IDENTIFIER_POINTER ($1), "packed") shouldn't we include them? */
&& strcmp (IDENTIFIER_POINTER ($1), "noreturn"))
warning ("`%s' attribute directive ignored", any_word:
IDENTIFIER_POINTER ($1)); identifier
$$ = $1; } | SCSPEC
| TYPE_QUAL | TYPESPEC
| identifier '(' expr_no_commas ')' | TYPE_QUAL
{ /* If not aligned(n) or section(name), then issue warning */ ;
if (strcmp (IDENTIFIER_POINTER ($1), "section") == 0
|| strcmp (IDENTIFIER_POINTER ($1), "mode") == 0)
{
if (TREE_CODE ($3) != STRING_CST)
{
error ("invalid argument in `%s' attribute",
IDENTIFIER_POINTER ($1));
$$ = $1;
}
$$ = tree_cons ($1, $3, NULL_TREE);
}
else if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0)
{
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1));
$$ = $1;
}
else
$$ = tree_cons ($1, $3, NULL_TREE); }
| identifier '(' IDENTIFIER ',' expr_no_commas ',' expr_no_commas ')'
{ /* if not "format(...)", then issue warning */
if (strcmp (IDENTIFIER_POINTER ($1), "format") != 0)
{
warning ("`%s' attribute directive ignored",
IDENTIFIER_POINTER ($1));
$$ = $1;
}
else
$$ = tree_cons ($1,
tree_cons ($3,
tree_cons ($5, $7, NULL_TREE),
NULL_TREE),
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