Commit 4b1e44be by Richard Henderson Committed by Richard Henderson

c-tree.h (C_DECL_FILE_SCOPE): Move ...

        * c-tree.h (C_DECL_FILE_SCOPE): Move ...
        * tree.h (DECL_FILE_SCOPE_P): ... here, and rename.
        * c-decl.c, c-objc-common.c, c-typeck.c: Update to match.

From-SVN: r70925
parent 05a5fba9
2003-08-29 Richard Henderson <rth@redhat.com>
* c-tree.h (C_DECL_FILE_SCOPE): Move ...
* tree.h (DECL_FILE_SCOPE_P): ... here, and rename.
* c-decl.c, c-objc-common.c, c-typeck.c: Update to match.
2003-08-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2003-08-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.def: Fix typos. * builtins.def: Fix typos.
......
...@@ -1571,7 +1571,7 @@ warn_if_shadowing (tree x, tree old) ...@@ -1571,7 +1571,7 @@ warn_if_shadowing (tree x, tree old)
name = IDENTIFIER_POINTER (DECL_NAME (x)); name = IDENTIFIER_POINTER (DECL_NAME (x));
if (TREE_CODE (old) == PARM_DECL) if (TREE_CODE (old) == PARM_DECL)
shadow_warning (SW_PARAM, name, old); shadow_warning (SW_PARAM, name, old);
else if (C_DECL_FILE_SCOPE (old)) else if (DECL_FILE_SCOPE_P (old))
shadow_warning (SW_GLOBAL, name, old); shadow_warning (SW_GLOBAL, name, old);
else else
shadow_warning (SW_LOCAL, name, old); shadow_warning (SW_LOCAL, name, old);
...@@ -1818,7 +1818,7 @@ implicitly_declare (tree functionid) ...@@ -1818,7 +1818,7 @@ implicitly_declare (tree functionid)
if (!C_DECL_IMPLICIT (decl)) if (!C_DECL_IMPLICIT (decl))
{ {
implicit_decl_warning (DECL_NAME (decl)); implicit_decl_warning (DECL_NAME (decl));
if (! C_DECL_FILE_SCOPE (decl)) if (! DECL_FILE_SCOPE_P (decl))
warning ("%Hprevious declaration of '%D'", warning ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (decl), decl); &DECL_SOURCE_LOCATION (decl), decl);
C_DECL_IMPLICIT (decl) = 1; C_DECL_IMPLICIT (decl) = 1;
...@@ -1898,7 +1898,7 @@ redeclaration_error_message (tree newdecl, tree olddecl) ...@@ -1898,7 +1898,7 @@ redeclaration_error_message (tree newdecl, tree olddecl)
return 1; return 1;
return 0; return 0;
} }
else if (C_DECL_FILE_SCOPE (newdecl)) else if (DECL_FILE_SCOPE_P (newdecl))
{ {
/* Objects declared at file scope: */ /* Objects declared at file scope: */
/* If at least one is a reference, it's ok. */ /* If at least one is a reference, it's ok. */
...@@ -2689,7 +2689,7 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes) ...@@ -2689,7 +2689,7 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
and we preserved the rtl from the previous one and we preserved the rtl from the previous one
(which may or may not happen). */ (which may or may not happen). */
&& !DECL_RTL_SET_P (tem) && !DECL_RTL_SET_P (tem)
&& C_DECL_FILE_SCOPE (tem)) && DECL_FILE_SCOPE_P (tem))
{ {
if (TREE_TYPE (tem) != error_mark_node if (TREE_TYPE (tem) != error_mark_node
&& (COMPLETE_TYPE_P (TREE_TYPE (tem)) && (COMPLETE_TYPE_P (TREE_TYPE (tem))
...@@ -2794,7 +2794,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2794,7 +2794,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
Otherwise, let it through, but if it is not `extern' Otherwise, let it through, but if it is not `extern'
then it may cause an error message later. */ then it may cause an error message later. */
(DECL_INITIAL (decl) != 0 (DECL_INITIAL (decl) != 0
|| !C_DECL_FILE_SCOPE (decl)) || !DECL_FILE_SCOPE_P (decl))
: :
/* An automatic variable with an incomplete type /* An automatic variable with an incomplete type
is an error. */ is an error. */
...@@ -2865,7 +2865,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2865,7 +2865,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
if (c_dialect_objc ()) if (c_dialect_objc ())
objc_check_decl (decl); objc_check_decl (decl);
if (C_DECL_FILE_SCOPE (decl)) if (DECL_FILE_SCOPE_P (decl))
{ {
if (DECL_INITIAL (decl) == NULL_TREE if (DECL_INITIAL (decl) == NULL_TREE
|| DECL_INITIAL (decl) == error_mark_node) || DECL_INITIAL (decl) == error_mark_node)
...@@ -2905,7 +2905,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2905,7 +2905,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
add_decl_stmt (decl); add_decl_stmt (decl);
} }
if (!C_DECL_FILE_SCOPE (decl)) if (!DECL_FILE_SCOPE_P (decl))
{ {
/* Recompute the RTL of a local array now /* Recompute the RTL of a local array now
if it used to be an incomplete type. */ if it used to be an incomplete type. */
...@@ -2930,7 +2930,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2930,7 +2930,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
/* This is a no-op in c-lang.c or something real in objc-act.c. */ /* This is a no-op in c-lang.c or something real in objc-act.c. */
if (c_dialect_objc ()) if (c_dialect_objc ())
objc_check_decl (decl); objc_check_decl (decl);
rest_of_decl_compilation (decl, NULL, C_DECL_FILE_SCOPE (decl), 0); rest_of_decl_compilation (decl, NULL, DECL_FILE_SCOPE_P (decl), 0);
} }
/* At the end of a declaration, throw away any variable type sizes /* At the end of a declaration, throw away any variable type sizes
...@@ -6308,7 +6308,7 @@ c_expand_body_1 (tree fndecl, int nested_p) ...@@ -6308,7 +6308,7 @@ c_expand_body_1 (tree fndecl, int nested_p)
to run global initializers, etc. */ to run global initializers, etc. */
if (DECL_NAME (fndecl) if (DECL_NAME (fndecl)
&& MAIN_NAME_P (DECL_NAME (fndecl)) && MAIN_NAME_P (DECL_NAME (fndecl))
&& C_DECL_FILE_SCOPE (fndecl)) && DECL_FILE_SCOPE_P (fndecl))
expand_main_function (); expand_main_function ();
/* Generate the RTL for this function. */ /* Generate the RTL for this function. */
...@@ -6640,7 +6640,7 @@ tree ...@@ -6640,7 +6640,7 @@ tree
identifier_global_value (tree t) identifier_global_value (tree t)
{ {
tree decl = IDENTIFIER_SYMBOL_VALUE (t); tree decl = IDENTIFIER_SYMBOL_VALUE (t);
if (decl == 0 || C_DECL_FILE_SCOPE (decl)) if (decl == 0 || DECL_FILE_SCOPE_P (decl))
return decl; return decl;
/* Shadowed by something else; find the true global value. */ /* Shadowed by something else; find the true global value. */
......
...@@ -127,7 +127,7 @@ inline_forbidden_p (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, ...@@ -127,7 +127,7 @@ inline_forbidden_p (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED,
/* We cannot inline a nested function that jumps to a nonlocal /* We cannot inline a nested function that jumps to a nonlocal
label. */ label. */
if (TREE_CODE (t) == LABEL_DECL if (TREE_CODE (t) == LABEL_DECL
&& !C_DECL_FILE_SCOPE (t) && DECL_CONTEXT (t) != fn) && !DECL_FILE_SCOPE_P (t) && DECL_CONTEXT (t) != fn)
return node; return node;
break; break;
...@@ -184,7 +184,7 @@ c_cannot_inline_tree_fn (tree *fnp) ...@@ -184,7 +184,7 @@ c_cannot_inline_tree_fn (tree *fnp)
goto cannot_inline; goto cannot_inline;
} }
if (! C_DECL_FILE_SCOPE (fn)) if (! DECL_FILE_SCOPE_P (fn))
{ {
/* If a nested function has pending sizes, we may have already /* If a nested function has pending sizes, we may have already
saved them. */ saved them. */
......
...@@ -138,11 +138,6 @@ struct lang_type GTY(()) ...@@ -138,11 +138,6 @@ struct lang_type GTY(())
|| (TYPE_ARG_TYPES (TREE_TYPE (EXP)) == 0 \ || (TYPE_ARG_TYPES (TREE_TYPE (EXP)) == 0 \
&& !DECL_BUILT_IN (EXP))) && !DECL_BUILT_IN (EXP)))
/* Nonzero for a decl which is at file scope. */
#define C_DECL_FILE_SCOPE(EXP) \
(! DECL_CONTEXT (EXP) \
|| TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL)
/* For FUNCTION_TYPE, a hidden list of types of arguments. The same as /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
TYPE_ARG_TYPES for functions with prototypes, but created for functions TYPE_ARG_TYPES for functions with prototypes, but created for functions
without prototypes. */ without prototypes. */
......
...@@ -1545,7 +1545,7 @@ build_external_ref (tree id, int fun) ...@@ -1545,7 +1545,7 @@ build_external_ref (tree id, int fun)
/* Properly declared variable or function reference. */ /* Properly declared variable or function reference. */
if (!objc_ivar) if (!objc_ivar)
ref = decl; ref = decl;
else if (decl != objc_ivar && !C_DECL_FILE_SCOPE (decl)) else if (decl != objc_ivar && !DECL_FILE_SCOPE_P (decl))
{ {
warning ("local declaration of `%s' hides instance variable", warning ("local declaration of `%s' hides instance variable",
IDENTIFIER_POINTER (id)); IDENTIFIER_POINTER (id));
...@@ -1585,7 +1585,7 @@ build_external_ref (tree id, int fun) ...@@ -1585,7 +1585,7 @@ build_external_ref (tree id, int fun)
TREE_CONSTANT (ref) = 1; TREE_CONSTANT (ref) = 1;
} }
else if (current_function_decl != 0 else if (current_function_decl != 0
&& !C_DECL_FILE_SCOPE (current_function_decl) && !DECL_FILE_SCOPE_P (current_function_decl)
&& (TREE_CODE (ref) == VAR_DECL && (TREE_CODE (ref) == VAR_DECL
|| TREE_CODE (ref) == PARM_DECL || TREE_CODE (ref) == PARM_DECL
|| TREE_CODE (ref) == FUNCTION_DECL)) || TREE_CODE (ref) == FUNCTION_DECL))
...@@ -2436,7 +2436,7 @@ build_unary_op (enum tree_code code, tree xarg, int flag) ...@@ -2436,7 +2436,7 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
file-scope function counts as a constant. */ file-scope function counts as a constant. */
if (staticp (arg) if (staticp (arg)
&& ! (TREE_CODE (arg) == FUNCTION_DECL && ! (TREE_CODE (arg) == FUNCTION_DECL
&& !C_DECL_FILE_SCOPE (arg))) && !DECL_FILE_SCOPE_P (arg)))
TREE_CONSTANT (addr) = 1; TREE_CONSTANT (addr) = 1;
return addr; return addr;
} }
......
...@@ -1624,6 +1624,11 @@ struct tree_type GTY(()) ...@@ -1624,6 +1624,11 @@ struct tree_type GTY(())
#define DECL_ESTIMATED_INSNS(NODE) \ #define DECL_ESTIMATED_INSNS(NODE) \
(FUNCTION_DECL_CHECK (NODE)->decl.u1.i) (FUNCTION_DECL_CHECK (NODE)->decl.u1.i)
/* Nonzero for a decl which is at file scope. */
#define DECL_FILE_SCOPE_P(EXP) \
(! DECL_CONTEXT (EXP) \
|| TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL)
struct function; struct function;
struct tree_decl GTY(()) struct tree_decl GTY(())
......
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