Commit f79f2651 by Neil Booth Committed by Neil Booth

c-parse.in (STATIC): New terminal.

	* c-parse.in (STATIC): New terminal.
	(scspec): New non-terminal.  Update productions accordingly.
	(program): Remove bogus ifc / end ifc.
	(array_declarator): Simplify production using STATIC.

From-SVN: r50155
parent 001e3fee
2002-02-28 Neil Booth <neil@daikokuya.demon.co.uk>
* c-parse.in (STATIC): New terminal.
(scspec): New non-terminal. Update productions accordingly.
(program): Remove bogus ifc / end ifc.
(array_declarator): Simplify production using STATIC.
2002-02-28 Jim Meyering <meyering@lucent.com> 2002-02-28 Jim Meyering <meyering@lucent.com>
* cpplex.c (cpp_parse_escape): Restore mistakenly-removed code: * cpplex.c (cpp_parse_escape): Restore mistakenly-removed code:
......
...@@ -85,7 +85,8 @@ end ifobjc ...@@ -85,7 +85,8 @@ end ifobjc
/* Reserved words that specify storage class. /* Reserved words that specify storage class.
yylval contains an IDENTIFIER_NODE which indicates which one. */ yylval contains an IDENTIFIER_NODE which indicates which one. */
%token SCSPEC %token SCSPEC /* Storage class other than static. */
%token STATIC /* Static storage class. */
/* Reserved words that specify type. /* Reserved words that specify type.
yylval contains an IDENTIFIER_NODE which indicates which one. */ yylval contains an IDENTIFIER_NODE which indicates which one. */
...@@ -167,7 +168,7 @@ end ifobjc ...@@ -167,7 +168,7 @@ end ifobjc
%type <ttype> typespec_reserved_nonattr typespec_reserved_attr %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
%type <ttype> typespec_nonreserved_nonattr %type <ttype> typespec_nonreserved_nonattr
%type <ttype> SCSPEC TYPESPEC TYPE_QUAL maybe_type_qual %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_type_qual
%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
...@@ -329,9 +330,10 @@ program: /* empty */ ...@@ -329,9 +330,10 @@ program: /* empty */
get us back to the global binding level. */ get us back to the global binding level. */
while (! global_bindings_p ()) while (! global_bindings_p ())
poplevel (0, 0, 0); poplevel (0, 0, 0);
ifc /* __FUNCTION__ is defined at file scope (""). This
call may not be necessary as my tests indicate it
still works without it. */
finish_fname_decls (); finish_fname_decls ();
end ifc
finish_file (); finish_file ();
} }
; ;
...@@ -854,7 +856,7 @@ decl: ...@@ -854,7 +856,7 @@ decl:
/* A list of declaration specifiers. These are: /* A list of declaration specifiers. These are:
- Storage class specifiers (SCSPEC), which for GCC currently include - Storage class specifiers (scspec), which for GCC currently includes
function specifiers ("inline"). function specifiers ("inline").
- Type specifiers (typespec_*). - Type specifiers (typespec_*).
...@@ -1025,7 +1027,7 @@ declspecs_nosc_ts_sa_ea: ...@@ -1025,7 +1027,7 @@ declspecs_nosc_ts_sa_ea:
; ;
declspecs_sc_nots_nosa_noea: declspecs_sc_nots_nosa_noea:
SCSPEC scspec
{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE); { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
TREE_STATIC ($$) = 0; } TREE_STATIC ($$) = 0; }
| declspecs_sc_nots_nosa_noea TYPE_QUAL | declspecs_sc_nots_nosa_noea TYPE_QUAL
...@@ -1034,25 +1036,25 @@ declspecs_sc_nots_nosa_noea: ...@@ -1034,25 +1036,25 @@ declspecs_sc_nots_nosa_noea:
| declspecs_sc_nots_nosa_ea TYPE_QUAL | declspecs_sc_nots_nosa_ea TYPE_QUAL
{ $$ = tree_cons (NULL_TREE, $2, $1); { $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = 1; } TREE_STATIC ($$) = 1; }
| declspecs_nosc_nots_nosa_noea SCSPEC | declspecs_nosc_nots_nosa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_nosc_nots_nosa_ea SCSPEC | declspecs_nosc_nots_nosa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_nots_nosa_noea SCSPEC | declspecs_sc_nots_nosa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_nots_nosa_ea SCSPEC | declspecs_sc_nots_nosa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
...@@ -1073,25 +1075,25 @@ declspecs_sc_nots_sa_noea: ...@@ -1073,25 +1075,25 @@ declspecs_sc_nots_sa_noea:
| declspecs_sc_nots_sa_ea TYPE_QUAL | declspecs_sc_nots_sa_ea TYPE_QUAL
{ $$ = tree_cons (NULL_TREE, $2, $1); { $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = 1; } TREE_STATIC ($$) = 1; }
| declspecs_nosc_nots_sa_noea SCSPEC | declspecs_nosc_nots_sa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_nosc_nots_sa_ea SCSPEC | declspecs_nosc_nots_sa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_nots_sa_noea SCSPEC | declspecs_sc_nots_sa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_nots_sa_ea SCSPEC | declspecs_sc_nots_sa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
...@@ -1124,25 +1126,25 @@ declspecs_sc_ts_nosa_noea: ...@@ -1124,25 +1126,25 @@ declspecs_sc_ts_nosa_noea:
| declspecs_sc_nots_nosa_ea typespec_nonattr | declspecs_sc_nots_nosa_ea typespec_nonattr
{ $$ = tree_cons (NULL_TREE, $2, $1); { $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = 1; } TREE_STATIC ($$) = 1; }
| declspecs_nosc_ts_nosa_noea SCSPEC | declspecs_nosc_ts_nosa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_nosc_ts_nosa_ea SCSPEC | declspecs_nosc_ts_nosa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_ts_nosa_noea SCSPEC | declspecs_sc_ts_nosa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_ts_nosa_ea SCSPEC | declspecs_sc_ts_nosa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
...@@ -1187,25 +1189,25 @@ declspecs_sc_ts_sa_noea: ...@@ -1187,25 +1189,25 @@ declspecs_sc_ts_sa_noea:
| declspecs_sc_nots_sa_ea typespec_nonattr | declspecs_sc_nots_sa_ea typespec_nonattr
{ $$ = tree_cons (NULL_TREE, $2, $1); { $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = 1; } TREE_STATIC ($$) = 1; }
| declspecs_nosc_ts_sa_noea SCSPEC | declspecs_nosc_ts_sa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_nosc_ts_sa_ea SCSPEC | declspecs_nosc_ts_sa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_ts_sa_noea SCSPEC | declspecs_sc_ts_sa_noea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
$$ = tree_cons (NULL_TREE, $2, $1); $$ = tree_cons (NULL_TREE, $2, $1);
TREE_STATIC ($$) = TREE_STATIC ($1); } TREE_STATIC ($$) = TREE_STATIC ($1); }
| declspecs_sc_ts_sa_ea SCSPEC | declspecs_sc_ts_sa_ea scspec
{ if (extra_warnings && TREE_STATIC ($1)) { if (extra_warnings && TREE_STATIC ($1))
warning ("`%s' is not at beginning of declaration", warning ("`%s' is not at beginning of declaration",
IDENTIFIER_POINTER ($2)); IDENTIFIER_POINTER ($2));
...@@ -1479,11 +1481,16 @@ attrib: ...@@ -1479,11 +1481,16 @@ attrib:
any_word: any_word:
identifier identifier
| SCSPEC | scspec
| TYPESPEC | TYPESPEC
| TYPE_QUAL | TYPE_QUAL
; ;
scspec:
STATIC
| SCSPEC
;
/* Initializers. `init' is the entry point. */ /* Initializers. `init' is the entry point. */
init: init:
...@@ -1972,30 +1979,17 @@ direct_absdcl1: ...@@ -1972,30 +1979,17 @@ direct_absdcl1:
/* The [...] part of a declarator for an array type. */ /* The [...] part of a declarator for an array type. */
array_declarator: array_declarator:
'[' expr ']' '[' maybe_type_quals_attrs expr ']'
{ $$ = build_array_declarator ($2, NULL_TREE, 0, 0); }
| '[' declspecs_nosc expr ']'
{ $$ = build_array_declarator ($3, $2, 0, 0); } { $$ = build_array_declarator ($3, $2, 0, 0); }
| '[' ']' | '[' maybe_type_quals_attrs ']'
{ $$ = build_array_declarator (NULL_TREE, NULL_TREE, 0, 0); }
| '[' declspecs_nosc ']'
{ $$ = build_array_declarator (NULL_TREE, $2, 0, 0); } { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
| '[' '*' ']' | '[' maybe_type_quals_attrs '*' ']'
{ $$ = build_array_declarator (NULL_TREE, NULL_TREE, 0, 1); }
| '[' declspecs_nosc '*' ']'
{ $$ = build_array_declarator (NULL_TREE, $2, 0, 1); } { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
| '[' SCSPEC expr ']' | '[' STATIC maybe_type_quals_attrs expr ']'
{ if (C_RID_CODE ($2) != RID_STATIC) { $$ = build_array_declarator ($4, $3, 1, 0); }
error ("storage class specifier in array declarator"); /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
$$ = build_array_declarator ($3, NULL_TREE, 1, 0); } | '[' declspecs_nosc_nots STATIC expr ']'
| '[' SCSPEC declspecs_nosc expr ']' { $$ = build_array_declarator ($4, $2, 1, 0); }
{ if (C_RID_CODE ($2) != RID_STATIC)
error ("storage class specifier in array declarator");
$$ = build_array_declarator ($4, $3, 1, 0); }
| '[' declspecs_nosc SCSPEC expr ']'
{ if (C_RID_CODE ($3) != RID_STATIC)
error ("storage class specifier in array declarator");
$$ = build_array_declarator ($4, $2, 1, 0); }
; ;
/* A nonempty series of declarations and statements (possibly followed by /* A nonempty series of declarations and statements (possibly followed by
...@@ -3402,7 +3396,7 @@ end ifobjc ...@@ -3402,7 +3396,7 @@ end ifobjc
three languages. */ three languages. */
static const short rid_to_yy[RID_MAX] = static const short rid_to_yy[RID_MAX] =
{ {
/* RID_STATIC */ SCSPEC, /* RID_STATIC */ STATIC,
/* RID_UNSIGNED */ TYPESPEC, /* RID_UNSIGNED */ TYPESPEC,
/* RID_LONG */ TYPESPEC, /* RID_LONG */ TYPESPEC,
/* RID_CONST */ TYPE_QUAL, /* RID_CONST */ TYPE_QUAL,
...@@ -3835,6 +3829,7 @@ yyprint (file, yychar, yyl) ...@@ -3835,6 +3829,7 @@ yyprint (file, yychar, yyl)
case TYPESPEC: case TYPESPEC:
case TYPE_QUAL: case TYPE_QUAL:
case SCSPEC: case SCSPEC:
case STATIC:
if (IDENTIFIER_POINTER (t)) if (IDENTIFIER_POINTER (t))
fprintf (file, " `%s'", IDENTIFIER_POINTER (t)); fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
break; break;
......
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