summaryrefslogtreecommitdiffstats
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-09 01:16:16 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-09 01:16:16 +0000
commit9823d3a9a666d8459764265abd3b04ead5c3def1 (patch)
treecafc9cbafbe798461e115c710492d5167b17d34a /gcc/c-decl.c
parent196bfa93bdbc9ac2c3e3f5104b6774bbbce7c150 (diff)
downloadppe42-gcc-9823d3a9a666d8459764265abd3b04ead5c3def1.tar.gz
ppe42-gcc-9823d3a9a666d8459764265abd3b04ead5c3def1.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87216 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 0ffda691861..5399c175d82 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -109,6 +109,11 @@ static location_t current_function_prototype_locus;
static GTY(()) tree current_function_arg_info;
+/* The obstack on which parser and related data structures, which are
+ not live beyond their top-level declaration or definition, are
+ allocated. */
+struct obstack parser_obstack;
+
/* The current statement tree. */
static GTY(()) struct stmt_tree_s c_stmt_tree;
@@ -2526,6 +2531,8 @@ c_init_decl_processing (void)
current_function_decl = 0;
+ gcc_obstack_init (&parser_obstack);
+
/* Make the externals scope. */
push_scope ();
external_scope = current_scope;
@@ -6936,7 +6943,21 @@ c_write_global_declarations_1 (tree globals)
/* Process the decls in the order they were written. */
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
- vec[i] = decl;
+ {
+ vec[i] = decl;
+ /* Check for used but undefined static functions using the C
+ standard's definition of "used", and set TREE_NO_WARNING so
+ that check_global_declarations doesn't repeat the check. */
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_INITIAL (decl) == 0
+ && DECL_EXTERNAL (decl)
+ && !TREE_PUBLIC (decl)
+ && C_DECL_USED (decl))
+ {
+ pedwarn ("%J%<%F%> used but never defined", decl, decl);
+ TREE_NO_WARNING (decl) = 1;
+ }
+ }
wrapup_global_declarations (vec, len);
check_global_declarations (vec, len);
OpenPOWER on IntegriCloud