summaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-25 16:38:31 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-25 16:38:31 +0000
commitf48c7f4a6a9a70f95dab2da3bcd5544eb513b4cf (patch)
treec06da7c9c228125d82710e24882cf0f1975caa4b /gcc/c
parent577041e3f5772d7793caff2b7aa93ebc05b89325 (diff)
downloadgcc-f48c7f4a6a9a70f95dab2da3bcd5544eb513b4cf.tar.gz
* array-notation-common.c: Use VAR_P throughout.
* c-ada-spec.c: Likewise. * c-common.c: Likewise. * c-format.c: Likewise. * c-gimplify.c: Likewise. * c-omp.c: Likewise. * c-pragma.c: Likewise. * c-pretty-print.c: Likewise. * cilk.c: Likewise. * c-array-notation.c: Use VAR_P throughout. * c-decl.c: Likewise. * c-objc-common.c: Likewise. * c-parser.c: Likewise. * c-typeck.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224949 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog8
-rw-r--r--gcc/c/c-array-notation.c2
-rw-r--r--gcc/c/c-decl.c53
-rw-r--r--gcc/c/c-objc-common.c2
-rw-r--r--gcc/c/c-parser.c4
-rw-r--r--gcc/c/c-typeck.c33
6 files changed, 53 insertions, 49 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index c8d1c24c064..6b3deac6cff 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,13 @@
2015-06-25 Marek Polacek <polacek@redhat.com>
+ * c-array-notation.c: Use VAR_P throughout.
+ * c-decl.c: Likewise.
+ * c-objc-common.c: Likewise.
+ * c-parser.c: Likewise.
+ * c-typeck.c: Likewise.
+
+2015-06-25 Marek Polacek <polacek@redhat.com>
+
* c-decl.c: Use is_global_var throughout.
* c-parser.c: Likewise.
* c-typeck.c: Likewise.
diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
index 2816680a995..02924688336 100644
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -87,7 +87,7 @@ make_triplet_val_inv (location_t loc, tree *value)
tree var, new_exp;
if (TREE_CODE (*value) != INTEGER_CST
&& TREE_CODE (*value) != PARM_DECL
- && TREE_CODE (*value) != VAR_DECL)
+ && !VAR_P (*value))
{
var = build_decl (loc, VAR_DECL, NULL_TREE, integer_type_node);
new_exp = build_modify_expr (loc, var, TREE_TYPE (var), NOP_EXPR, loc,
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 1aa2bd49669..fb4a83c0bd7 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
diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c
index 0bd331608c3..a783f805b28 100644
--- a/gcc/c/c-objc-common.c
+++ b/gcc/c/c-objc-common.c
@@ -109,7 +109,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
switch (*spec)
{
case 'D':
- if (TREE_CODE (t) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (t))
+ if (VAR_P (t) && DECL_HAS_DEBUG_EXPR_P (t))
{
t = DECL_DEBUG_EXPR (t);
if (!DECL_P (t))
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index f4d18bdaed2..aaf7e326c99 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -10365,7 +10365,7 @@ c_parser_oacc_data_clause_deviceptr (c_parser *parser, tree list)
c_parser_omp_var_list_parens() should construct a list of
locations to go along with the var list. */
- if (TREE_CODE (v) != VAR_DECL)
+ if (!VAR_P (v))
error_at (loc, "%qD is not a variable", v);
else if (TREE_TYPE (v) == error_mark_node)
;
@@ -14765,7 +14765,7 @@ c_parser_omp_threadprivate (c_parser *parser)
/* If V had already been marked threadprivate, it doesn't matter
whether it had been used prior to this point. */
- if (TREE_CODE (v) != VAR_DECL)
+ if (!VAR_P (v))
error_at (loc, "%qD is not a variable", v);
else if (TREE_USED (v) && !C_DECL_THREADPRIVATE_P (v))
error_at (loc, "%qE declared %<threadprivate%> after first use", v);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 7ca6e6af730..9caf028b0b1 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -219,8 +219,7 @@ c_incomplete_type_error (const_tree value, const_tree type)
if (TREE_CODE (type) == ERROR_MARK)
return;
- if (value != 0 && (TREE_CODE (value) == VAR_DECL
- || TREE_CODE (value) == PARM_DECL))
+ if (value != 0 && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
error ("%qD has an incomplete type %qT", value, type);
else
{
@@ -2531,7 +2530,7 @@ build_array_ref (location_t loc, tree array, tree index)
tree foo = array;
while (TREE_CODE (foo) == COMPONENT_REF)
foo = TREE_OPERAND (foo, 0);
- if (TREE_CODE (foo) == VAR_DECL && C_DECL_REGISTER (foo))
+ if (VAR_P (foo) && C_DECL_REGISTER (foo))
pedwarn (loc, OPT_Wpedantic,
"ISO C forbids subscripting %<register%> array");
else if (!lvalue_p (foo))
@@ -2673,7 +2672,7 @@ build_external_ref (location_t loc, tree id, int fun, tree *type)
&& DECL_DECLARED_INLINE_P (current_function_decl)
&& DECL_EXTERNAL (current_function_decl)
&& VAR_OR_FUNCTION_DECL_P (ref)
- && (TREE_CODE (ref) != VAR_DECL || TREE_STATIC (ref))
+ && (!VAR_P (ref) || TREE_STATIC (ref))
&& ! TREE_PUBLIC (ref)
&& DECL_CONTEXT (ref) != current_function_decl)
record_inline_static (loc, current_function_decl, ref,
@@ -11589,7 +11588,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
{
if (error_operand_p (t))
return error_mark_node;
- if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
if (DECL_P (t))
error_at (OMP_CLAUSE_LOCATION (c),
@@ -11602,7 +11601,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
return error_mark_node;
}
else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
- && TREE_CODE (t) == VAR_DECL && DECL_THREAD_LOCAL_P (t))
+ && VAR_P (t) && DECL_THREAD_LOCAL_P (t))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qD is threadprivate variable in %qs clause", t,
@@ -12198,7 +12197,7 @@ c_finish_omp_clauses (tree clauses)
case OMP_CLAUSE_COPYIN:
t = OMP_CLAUSE_DECL (c);
- if (TREE_CODE (t) != VAR_DECL || !DECL_THREAD_LOCAL_P (t))
+ if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE must be %<threadprivate%> for %<copyin%>", t);
@@ -12236,7 +12235,7 @@ c_finish_omp_clauses (tree clauses)
check_dup_generic:
t = OMP_CLAUSE_DECL (c);
- if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is not a variable in clause %qs", t,
@@ -12259,7 +12258,7 @@ c_finish_omp_clauses (tree clauses)
t = OMP_CLAUSE_DECL (c);
need_complete = true;
need_implicitly_determined = true;
- if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is not a variable in clause %<firstprivate%>", t);
@@ -12280,7 +12279,7 @@ c_finish_omp_clauses (tree clauses)
t = OMP_CLAUSE_DECL (c);
need_complete = true;
need_implicitly_determined = true;
- if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is not a variable in clause %<lastprivate%>", t);
@@ -12299,7 +12298,7 @@ c_finish_omp_clauses (tree clauses)
case OMP_CLAUSE_ALIGNED:
t = OMP_CLAUSE_DECL (c);
- if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is not a variable in %<aligned%> clause", t);
@@ -12334,7 +12333,7 @@ c_finish_omp_clauses (tree clauses)
}
if (t == error_mark_node)
remove = true;
- else if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is not a variable in %<depend%> clause", t);
@@ -12369,14 +12368,14 @@ c_finish_omp_clauses (tree clauses)
}
if (t == error_mark_node)
remove = true;
- else if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+ else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is not a variable in %qs clause", t,
omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
- else if (TREE_CODE (t) == VAR_DECL && DECL_THREAD_LOCAL_P (t))
+ else if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qD is threadprivate variable in %qs clause", t,
@@ -12503,7 +12502,7 @@ c_finish_omp_clauses (tree clauses)
{
const char *share_name = NULL;
- if (TREE_CODE (t) == VAR_DECL && DECL_THREAD_LOCAL_P (t))
+ if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
share_name = "threadprivate";
else switch (c_omp_predetermined_sharing (t))
{
@@ -12752,10 +12751,10 @@ c_tree_equal (tree t1, tree t2)
it means that it's going to be unified with whatever the
TARGET_EXPR is really supposed to initialize, so treat it
as being equivalent to anything. */
- if (TREE_CODE (o1) == VAR_DECL && DECL_NAME (o1) == NULL_TREE
+ if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
&& !DECL_RTL_SET_P (o1))
/*Nop*/;
- else if (TREE_CODE (o2) == VAR_DECL && DECL_NAME (o2) == NULL_TREE
+ else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
&& !DECL_RTL_SET_P (o2))
/*Nop*/;
else if (!c_tree_equal (o1, o2))