summaryrefslogtreecommitdiff
path: root/gcc/c-parse.in
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2004-09-09 02:16:16 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2004-09-09 02:16:16 +0100
commitbc4b653be6451211226018f96146a1eaa439b6cd (patch)
treecafc9cbafbe798461e115c710492d5167b17d34a /gcc/c-parse.in
parent1835f9efd2e8bac8a4a44497915f37f45144e932 (diff)
downloadgcc-bc4b653be6451211226018f96146a1eaa439b6cd.tar.gz
c-tree.h (C_DECL_USED, [...]): New.
* c-tree.h (C_DECL_USED, parser_obstack, in_alignof, in_sizeof, in_typeof, record_maybe_used_decl, pop_maybe_used, c_expr_sizeof_expr, c_expr_sizeof_type): New. * c-decl.c (parser_obstack): New. (c_init_decl_processing): Initialize parser_obstack. (c_write_global_declarations_1): Check for used but undefined static functions. * c-parse.in (%union): Add otype. (save_obstack_position): New. (extdefs): Use it. (unary_expr): Update in_sizeof and in_alignof. Use c_expr_sizeof_expr and c_expr_sizeof_type. (sizeof): Update in_sizeof. (alignof): Update in_alignof. (typeof): Update in_typeof. (typespec_nonreserved_nonattr): Call pop_maybe_used. * c-typeck.c (in_alignof, in_sizeof, in_typeof, struct maybe_used_decl, maybe_used_decls, record_maybe_used_decl, pop_maybe_used, c_expr_sizeof_expr, c_expr_sizeof_type): New. (build_external_ref): Set C_DECL_USED or call record_maybe_used_decl if appropriate. * toplev.c (check_global_declarations): Check TREE_NO_WARNING. testsuite: * gcc.dg/c90-static-1.c, gcc.dg/c99-static-1.c, gcc.dg/gnu99-static-1.c: New tests. From-SVN: r87216
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r--gcc/c-parse.in42
1 files changed, 29 insertions, 13 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 9774bcf461d..fff001faa17 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -99,8 +99,8 @@ do { \
%start program
-%union {long itype; tree ttype; struct c_expr exprtype; enum tree_code code;
- location_t location; }
+%union {long itype; tree ttype; void *otype; struct c_expr exprtype;
+ enum tree_code code; location_t location; }
/* All identifiers that are not reserved words
and are not declared typedefs in the current block */
@@ -241,6 +241,8 @@ do { \
%type <itype> setspecs setspecs_fp extension
%type <location> save_location
+
+%type <otype> save_obstack_position
@@ifobjc
/* the Objective-C nonterminals */
@@ -360,8 +362,11 @@ program: /* empty */
can find a valid list of type and sc specs in $0. */
extdefs:
- {$<ttype>$ = NULL_TREE; } extdef
- | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
+ save_obstack_position { $<ttype>$ = NULL_TREE; } extdef
+ { obstack_free (&parser_obstack, $1); }
+ | extdefs save_obstack_position
+ { $<ttype>$ = NULL_TREE; ggc_collect(); } extdef
+ { obstack_free (&parser_obstack, $2); }
;
extdef:
@@ -375,6 +380,12 @@ extdef:
@@end_ifobjc
;
+/* Record the current position of parser_obstack before a
+ declaration to restore it afterwards. */
+save_obstack_position:
+ { $$ = obstack_alloc (&parser_obstack, 0); }
+ ;
+
datadef:
setspecs notype_initdecls ';'
{ if (pedantic)
@@ -506,21 +517,23 @@ unary_expr:
$$.original_code = ERROR_MARK; }
| sizeof unary_expr %prec UNARY
{ skip_evaluation--;
+ in_sizeof--;
if (TREE_CODE ($2.value) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND ($2.value, 1)))
error ("`sizeof' applied to a bit-field");
- $$.value = c_sizeof (TREE_TYPE ($2.value));
- $$.original_code = ERROR_MARK; }
+ $$ = c_expr_sizeof_expr ($2); }
| sizeof '(' typename ')' %prec HYPERUNARY
{ skip_evaluation--;
- $$.value = c_sizeof (groktypename ($3));
- $$.original_code = ERROR_MARK; }
+ in_sizeof--;
+ $$ = c_expr_sizeof_type ($3); }
| alignof unary_expr %prec UNARY
{ skip_evaluation--;
+ in_alignof--;
$$.value = c_alignof_expr ($2.value);
$$.original_code = ERROR_MARK; }
| alignof '(' typename ')' %prec HYPERUNARY
{ skip_evaluation--;
+ in_alignof--;
$$.value = c_alignof (groktypename ($3));
$$.original_code = ERROR_MARK; }
| REALPART cast_expr %prec UNARY
@@ -532,15 +545,15 @@ unary_expr:
;
sizeof:
- SIZEOF { skip_evaluation++; }
+ SIZEOF { skip_evaluation++; in_sizeof++; }
;
alignof:
- ALIGNOF { skip_evaluation++; }
+ ALIGNOF { skip_evaluation++; in_alignof++; }
;
typeof:
- TYPEOF { skip_evaluation++; }
+ TYPEOF { skip_evaluation++; in_typeof++; }
;
cast_expr:
@@ -1376,12 +1389,15 @@ typespec_nonreserved_nonattr:
@@end_ifobjc
| typeof '(' expr ')'
{ skip_evaluation--;
+ in_typeof--;
if (TREE_CODE ($3.value) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
error ("`typeof' applied to a bit-field");
- $$ = TREE_TYPE ($3.value); }
+ $$ = TREE_TYPE ($3.value);
+ pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); }
| typeof '(' typename ')'
- { skip_evaluation--; $$ = groktypename ($3); }
+ { skip_evaluation--; in_typeof--; $$ = groktypename ($3);
+ pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); }
;
/* typespec_nonreserved_attr does not exist. */