aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 1aa2bd4..fb4a83c 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -669,14 +669,14 @@ decl_jump_unsafe (tree decl)
return false;
/* Always warn about crossing variably modified types. */
- if ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == TYPE_DECL)
+ if ((VAR_P (decl) || TREE_CODE (decl) == TYPE_DECL)
&& variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
return true;
/* Otherwise, only warn if -Wgoto-misses-init and this is an
initialized automatic decl. */
if (warn_jump_misses_init
- && TREE_CODE (decl) == VAR_DECL
+ && VAR_P (decl)
&& !TREE_STATIC (decl)
&& DECL_INITIAL (decl) != NULL_TREE)
return true;
@@ -817,7 +817,7 @@ bind_label (tree name, tree label, struct c_scope *scope,
void
c_finish_incomplete_decl (tree decl)
{
- if (TREE_CODE (decl) == VAR_DECL)
+ if (VAR_P (decl))
{
tree type = TREE_TYPE (decl);
if (type != error_mark_node
@@ -1599,7 +1599,7 @@ c_bind (location_t loc, tree decl, bool is_global)
struct c_scope *scope;
bool nested = false;
- if (TREE_CODE (decl) != VAR_DECL || current_function_scope == NULL)
+ if (!VAR_P (decl) || current_function_scope == NULL)
{
/* Types and functions are always considered to be global. */
scope = file_scope;
@@ -2111,7 +2111,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
}
}
}
- else if (TREE_CODE (newdecl) == VAR_DECL)
+ else if (VAR_P (newdecl))
{
/* Only variables can be thread-local, and all declarations must
agree on this property. */
@@ -2306,7 +2306,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
&& !(TREE_CODE (newdecl) == PARM_DECL
&& TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
/* Don't warn about a variable definition following a declaration. */
- && !(TREE_CODE (newdecl) == VAR_DECL
+ && !(VAR_P (newdecl)
&& DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
{
warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D",
@@ -2427,7 +2427,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
/* Merge the threadprivate attribute. */
- if (TREE_CODE (olddecl) == VAR_DECL && C_DECL_THREADPRIVATE_P (olddecl))
+ if (VAR_P (olddecl) && C_DECL_THREADPRIVATE_P (olddecl))
C_DECL_THREADPRIVATE_P (newdecl) = 1;
if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS))
@@ -2611,7 +2611,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
TREE_USED (newdecl) = 1;
else if (TREE_USED (newdecl))
TREE_USED (olddecl) = 1;
- if (TREE_CODE (olddecl) == VAR_DECL || TREE_CODE (olddecl) == PARM_DECL)
+ if (VAR_P (olddecl) || TREE_CODE (olddecl) == PARM_DECL)
DECL_READ_P (newdecl) |= DECL_READ_P (olddecl);
if (DECL_PRESERVE_P (olddecl))
DECL_PRESERVE_P (newdecl) = 1;
@@ -2660,8 +2660,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
int __thread x attribute ((tls_model ("local-exec")));
extern int __thread x;
as we'll lose the "local-exec" model. */
- if (TREE_CODE (olddecl) == VAR_DECL
- && DECL_THREAD_LOCAL_P (newdecl))
+ if (VAR_P (olddecl) && DECL_THREAD_LOCAL_P (newdecl))
set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
break;
}
@@ -2694,8 +2693,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
flags and attributes. */
if (DECL_RTL_SET_P (olddecl)
&& (TREE_CODE (olddecl) == FUNCTION_DECL
- || (TREE_CODE (olddecl) == VAR_DECL
- && TREE_STATIC (olddecl))))
+ || (VAR_P (olddecl) && TREE_STATIC (olddecl))))
make_decl_rtl (olddecl);
}
@@ -2944,7 +2942,7 @@ pushdecl (tree x)
type_saved = true;
}
if (B_IN_FILE_SCOPE (b)
- && TREE_CODE (b->decl) == VAR_DECL
+ && VAR_P (b->decl)
&& TREE_STATIC (b->decl)
&& TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE
&& !TYPE_DOMAIN (TREE_TYPE (b->decl))
@@ -3075,7 +3073,7 @@ pushdecl_top_level (tree x)
{
tree name;
bool nested = false;
- gcc_assert (TREE_CODE (x) == VAR_DECL || TREE_CODE (x) == CONST_DECL);
+ gcc_assert (VAR_P (x) || TREE_CODE (x) == CONST_DECL);
name = DECL_NAME (x);
@@ -4394,17 +4392,16 @@ c_decl_attributes (tree *node, tree attributes, int flags)
{
/* Add implicit "omp declare target" attribute if requested. */
if (current_omp_declare_target_attribute
- && ((TREE_CODE (*node) == VAR_DECL
- && is_global_var (*node))
+ && ((VAR_P (*node) && is_global_var (*node))
|| TREE_CODE (*node) == FUNCTION_DECL))
{
- if (TREE_CODE (*node) == VAR_DECL
+ if (VAR_P (*node)
&& ((DECL_CONTEXT (*node)
&& TREE_CODE (DECL_CONTEXT (*node)) == FUNCTION_DECL)
|| (current_function_decl && !DECL_EXTERNAL (*node))))
error ("%q+D in block scope inside of declare target directive",
*node);
- else if (TREE_CODE (*node) == VAR_DECL
+ else if (VAR_P (*node)
&& !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node)))
error ("%q+D in declare target directive does not have mappable type",
*node);
@@ -4542,7 +4539,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
body of code to break, and it allows more efficient variable references
in the presence of dynamic linking. */
- if (TREE_CODE (decl) == VAR_DECL
+ if (VAR_P (decl)
&& !initialized
&& TREE_PUBLIC (decl)
&& !DECL_THREAD_LOCAL_P (decl)
@@ -4595,7 +4592,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
/* C99 6.7.4p3: An inline definition of a function with external
linkage shall not contain a definition of a modifiable object
with static storage duration... */
- if (TREE_CODE (decl) == VAR_DECL
+ if (VAR_P (decl)
&& current_scope != file_scope
&& TREE_STATIC (decl)
&& !TREE_READONLY (decl)
@@ -4673,7 +4670,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
if (asmspec_tree)
asmspec = TREE_STRING_POINTER (asmspec_tree);
- if (TREE_CODE (decl) == VAR_DECL
+ if (VAR_P (decl)
&& TREE_STATIC (decl)
&& global_bindings_p ())
/* So decl is a global variable. Record the types it uses
@@ -4766,7 +4763,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
relayout_decl (decl);
}
- if (TREE_CODE (decl) == VAR_DECL)
+ if (VAR_P (decl))
{
if (init && TREE_CODE (init) == CONSTRUCTOR)
add_flexible_array_elts_to_size (decl, init);
@@ -4847,7 +4844,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
GCC has accepted -- but ignored -- the ASMSPEC in
this case. */
if (!DECL_FILE_SCOPE_P (decl)
- && TREE_CODE (decl) == VAR_DECL
+ && VAR_P (decl)
&& !C_DECL_REGISTER (decl)
&& !TREE_STATIC (decl))
warning (0, "ignoring asm-specifier for non-static local "
@@ -4931,7 +4928,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
}
/* Install a cleanup (aka destructor) if one was given. */
- if (TREE_CODE (decl) == VAR_DECL && !TREE_STATIC (decl))
+ if (VAR_P (decl) && !TREE_STATIC (decl))
{
tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
if (attr)
@@ -4959,7 +4956,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
}
if (warn_cxx_compat
- && TREE_CODE (decl) == VAR_DECL
+ && VAR_P (decl)
&& !DECL_EXTERNAL (decl)
&& DECL_INITIAL (decl) == NULL_TREE)
{
@@ -6636,7 +6633,7 @@ grokdeclarator (const struct c_declarator *declarator,
if (global_decl
&& global_decl != visible_decl
- && TREE_CODE (global_decl) == VAR_DECL
+ && VAR_P (global_decl)
&& !TREE_PUBLIC (global_decl))
error_at (loc, "variable previously declared %<static%> "
"redeclared %<extern%>");
@@ -6715,7 +6712,7 @@ grokdeclarator (const struct c_declarator *declarator,
will be ignored, and would even crash the compiler.
Of course, this only makes sense on VAR,PARM, and RESULT decl's. */
if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))
- && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL
+ && (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL))
{
/* It is not an error for a structure with volatile fields to
@@ -6733,7 +6730,7 @@ grokdeclarator (const struct c_declarator *declarator,
gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl));
if (warn_cxx_compat
- && TREE_CODE (decl) == VAR_DECL
+ && VAR_P (decl)
&& TREE_PUBLIC (decl)
&& TREE_STATIC (decl)
&& (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE