From 56a6f1d33f7259fde0efc9c37a1308c306590e8b Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Sat, 27 Jun 2015 10:39:31 +0000 Subject: [PATCH] call.c (set_up_extended_ref_temp): Use VAR_P. * call.c (set_up_extended_ref_temp): Use VAR_P. * class.c: Use VAR_P throughout. * constexpr.c (cxx_eval_constant_expression): Use VAR_P. * cp-array-notation.c (make_triplet_val_inv): Likewise. * decl.c: Use VAR_OR_FUNCTION_DECL_P or VAR_P throughout. * decl2.c: Likewise. * error.c (dump_decl): Use VAR_P. * mangle.c (decl_implicit_alias_p): Likewise. * parser.c: Use VAR_P throughout. * pt.c: Likewise. * semantics.c: Likewise. * vtable-class-hierarchy.c: Likewise. * tree.c (handle_abi_tag_attribute): Use VAR_OR_FUNCTION_DECL_P. From-SVN: r225098 --- gcc/cp/ChangeLog | 17 +++++++++++++++++ gcc/cp/call.c | 2 +- gcc/cp/class.c | 6 +++--- gcc/cp/constexpr.c | 2 +- gcc/cp/cp-array-notation.c | 2 +- gcc/cp/decl.c | 17 ++++++++--------- gcc/cp/decl2.c | 27 +++++++++++++-------------- gcc/cp/error.c | 2 +- gcc/cp/mangle.c | 3 +-- gcc/cp/parser.c | 4 ++-- gcc/cp/pt.c | 8 ++++---- gcc/cp/semantics.c | 14 +++++++------- gcc/cp/tree.c | 3 +-- gcc/cp/vtable-class-hierarchy.c | 6 +++--- 14 files changed, 63 insertions(+), 50 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b00b8ae61ec..c93ef3a338e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,20 @@ +2015-06-27 Marek Polacek + + * call.c (set_up_extended_ref_temp): Use VAR_P. + * class.c: Use VAR_P throughout. + * constexpr.c (cxx_eval_constant_expression): Use VAR_P. + * cp-array-notation.c (make_triplet_val_inv): Likewise. + * decl.c: Use VAR_OR_FUNCTION_DECL_P or VAR_P + throughout. + * decl2.c: Likewise. + * error.c (dump_decl): Use VAR_P. + * mangle.c (decl_implicit_alias_p): Likewise. + * parser.c: Use VAR_P throughout. + * pt.c: Likewise. + * semantics.c: Likewise. + * vtable-class-hierarchy.c: Likewise. + * tree.c (handle_abi_tag_attribute): Use VAR_OR_FUNCTION_DECL_P. + 2015-06-27 Andreas Schwab * pt.c (check_unstripped_args): Mark parameter as unused. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 0e8840bb07e..e5ed53b8959 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -9697,7 +9697,7 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups, } /* Avoid -Wunused-variable warning (c++/38958). */ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type) - && TREE_CODE (decl) == VAR_DECL) + && VAR_P (decl)) TREE_USED (decl) = DECL_READ_P (decl) = true; *initp = init; diff --git a/gcc/cp/class.c b/gcc/cp/class.c index be31de21d3b..2547b91e0d9 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1399,7 +1399,7 @@ check_tag (tree tag, tree id, tree *tp, abi_tag_data *p) p->t, tag, *tp)) inform (location_of (*tp), "%qT declared here", *tp); } - else if (TREE_CODE (p->t) == VAR_DECL) + else if (VAR_P (p->t)) { if (warning (OPT_Wabi_tag, "%qD inherits the %E ABI tag " "that %qT (used in its type) has", p->t, tag, *tp)) @@ -1588,7 +1588,7 @@ check_abi_tags (tree t, tree subob) void check_abi_tags (tree decl) { - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) check_abi_tags (decl, TREE_TYPE (decl)); else if (TREE_CODE (decl) == FUNCTION_DECL && !mangle_return_type_p (decl)) @@ -3040,7 +3040,7 @@ finish_struct_anon_r (tree field, bool complain) { /* We already complained about static data members in finish_static_data_member_decl. */ - if (complain && TREE_CODE (elt) != VAR_DECL) + if (complain && !VAR_P (elt)) { if (is_union) permerror (input_location, diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9cb45eade41..4fce5e0506e 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3033,7 +3033,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (TREE_CODE (r) == TARGET_EXPR && TREE_CODE (TARGET_EXPR_INITIAL (r)) == CONSTRUCTOR) r = TARGET_EXPR_INITIAL (r); - if (TREE_CODE (r) == VAR_DECL) + if (VAR_P (r)) if (tree *p = ctx->values->get (r)) r = *p; if (DECL_P (r)) diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 9b8034ec8e2..a84efd5b151 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -87,7 +87,7 @@ make_triplet_val_inv (tree *value) { if (TREE_CODE (*value) != INTEGER_CST && TREE_CODE (*value) != PARM_DECL - && TREE_CODE (*value) != VAR_DECL) + && !VAR_P (*value)) *value = get_temp_regvar (ptrdiff_type_node, *value); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1fa28b2f608..959422341b2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2476,14 +2476,15 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) { struct symtab_node *snode = NULL; - if (TREE_CODE (newdecl) == VAR_DECL - && (TREE_STATIC (olddecl) || TREE_PUBLIC (olddecl) || DECL_EXTERNAL (olddecl))) + if (VAR_P (newdecl) + && (TREE_STATIC (olddecl) || TREE_PUBLIC (olddecl) + || DECL_EXTERNAL (olddecl))) snode = symtab_node::get (olddecl); memcpy ((char *) olddecl + sizeof (struct tree_decl_common), (char *) newdecl + sizeof (struct tree_decl_common), size - sizeof (struct tree_decl_common) + TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *)); - if (TREE_CODE (newdecl) == VAR_DECL) + if (VAR_P (newdecl)) olddecl->decl_with_vis.symtab_node = snode; } break; @@ -2496,8 +2497,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } } - if (TREE_CODE (newdecl) == FUNCTION_DECL - || TREE_CODE (newdecl) == VAR_DECL) + if (VAR_OR_FUNCTION_DECL_P (newdecl)) { if (DECL_EXTERNAL (olddecl) || TREE_PUBLIC (olddecl) @@ -2522,7 +2522,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } } - if (TREE_CODE (newdecl) == VAR_DECL + if (VAR_P (newdecl) && DECL_THREAD_LOCAL_P (newdecl)) set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl)); } @@ -2559,8 +2559,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) structure is shared in between newdecl and oldecl. */ if (TREE_CODE (newdecl) == FUNCTION_DECL) DECL_STRUCT_FUNCTION (newdecl) = NULL; - if (TREE_CODE (newdecl) == FUNCTION_DECL - || TREE_CODE (newdecl) == VAR_DECL) + if (VAR_OR_FUNCTION_DECL_P (newdecl)) { struct symtab_node *snode = symtab_node::get (newdecl); if (snode) @@ -4828,7 +4827,7 @@ start_decl (const cp_declarator *declarator, /* Enter this declaration into the symbol table. Don't push the plain VAR_DECL for a variable template. */ if (!template_parm_scope_p () - || TREE_CODE (decl) != VAR_DECL) + || !VAR_P (decl)) decl = maybe_push_decl (decl); if (processing_template_decl) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index f045253a1ab..da531fa1292 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1005,7 +1005,7 @@ grokfield (const cp_declarator *declarator, return value; /* Need to set this before push_template_decl. */ - if (TREE_CODE (value) == VAR_DECL) + if (VAR_P (value)) DECL_CONTEXT (value) = current_class_type; if (processing_template_decl && VAR_OR_FUNCTION_DECL_P (value)) @@ -1417,7 +1417,7 @@ cp_omp_mappable_type (tree type) { tree field; for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) - if (TREE_CODE (field) == VAR_DECL) + if (VAR_P (field)) return false; /* All fields must have mappable types. */ else if (TREE_CODE (field) == FIELD_DECL @@ -1438,21 +1438,21 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags) /* Add implicit "omp declare target" attribute if requested. */ if (scope_chain->omp_declare_target_attribute - && ((TREE_CODE (*decl) == VAR_DECL + && ((VAR_P (*decl) && (TREE_STATIC (*decl) || DECL_EXTERNAL (*decl))) || TREE_CODE (*decl) == FUNCTION_DECL)) { - if (TREE_CODE (*decl) == VAR_DECL + if (VAR_P (*decl) && DECL_CLASS_SCOPE_P (*decl)) error ("%q+D static data member inside of declare target directive", *decl); - else if (TREE_CODE (*decl) == VAR_DECL + else if (VAR_P (*decl) && (DECL_FUNCTION_SCOPE_P (*decl) || (current_function_decl && !DECL_EXTERNAL (*decl)))) error ("%q+D in block scope inside of declare target directive", *decl); else if (!processing_template_decl - && TREE_CODE (*decl) == VAR_DECL + && VAR_P (*decl) && !cp_omp_mappable_type (TREE_TYPE (*decl))) error ("%q+D in declare target directive does not have mappable type", *decl); @@ -1980,7 +1980,7 @@ mark_needed (tree decl) FOR_EACH_CLONE (clone, decl) mark_needed (clone); } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) { varpool_node *node = varpool_node::get_create (decl); /* C++ frontend use mark_decl_references to force COMDAT variables @@ -2179,8 +2179,7 @@ constrain_visibility (tree decl, int visibility, bool tmpl) DECL_WEAK (decl) = 0; DECL_COMMON (decl) = 0; DECL_COMDAT (decl) = false; - if (TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == VAR_DECL) + if (VAR_OR_FUNCTION_DECL_P (decl)) { struct symtab_node *snode = symtab_node::get (decl); @@ -2643,7 +2642,7 @@ reset_type_linkage_2 (tree type) reset_decl_linkage (ti); } for (tree m = TYPE_FIELDS (type); m; m = DECL_CHAIN (m)) - if (TREE_CODE (m) == VAR_DECL) + if (VAR_P (m)) reset_decl_linkage (m); for (tree m = TYPE_METHODS (type); m; m = DECL_CHAIN (m)) { @@ -2701,7 +2700,7 @@ tentative_decl_linkage (tree decl) DECL_INTERFACE_KNOWN (decl) = 1; } } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) maybe_commonize_var (decl); } } @@ -4208,7 +4207,7 @@ no_linkage_error (tree decl) "anonymous type, is used but never defined", decl); else if (DECL_EXTERN_C_P (decl)) /* Allow this; it's pretty common in C. */; - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) /* DRs 132, 319 and 389 seem to indicate types with no linkage can only be used to declare extern "C" entities. Since it's not always an error in the @@ -4227,12 +4226,12 @@ no_linkage_error (tree decl) } else if (cxx_dialect >= cxx11) { - if (TREE_CODE (decl) == VAR_DECL || !DECL_PURE_VIRTUAL_P (decl)) + if (VAR_P (decl) || !DECL_PURE_VIRTUAL_P (decl)) permerror (DECL_SOURCE_LOCATION (decl), "%q#D, declared using local type " "%qT, is used but never defined", decl, t); } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) warning_at (DECL_SOURCE_LOCATION (decl), 0, "type %qT with no linkage " "used to declare variable %q#D with linkage", t, decl); else diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 96fa94d50e0..3710046bbef 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1065,7 +1065,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) dump_simple_decl (pp, t, TREE_TYPE (t), flags); /* Handle variable template specializations. */ - if (TREE_CODE (t) == VAR_DECL + if (VAR_P (t) && DECL_LANG_SPECIFIC (t) && DECL_TEMPLATE_INFO (t) && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t))) diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index f4947c484d3..6246632710f 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3530,8 +3530,7 @@ decl_implicit_alias_p (tree decl) if (DECL_P (decl) && DECL_ARTIFICIAL (decl) && DECL_IGNORED_P (decl) && (TREE_CODE (decl) == FUNCTION_DECL - || (TREE_CODE (decl) == VAR_DECL - && TREE_STATIC (decl)))) + || (VAR_P (decl) && TREE_STATIC (decl)))) { symtab_node *n = symtab_node::get (decl); if (n && n->cpp_implicit_alias) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6dc79ac6045..acf147c0e5c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10571,7 +10571,7 @@ cp_convert_range_for (tree statement, tree range_decl, tree range_expr, { tree range_temp; - if (TREE_CODE (range_expr) == VAR_DECL + if (VAR_P (range_expr) && array_of_runtime_bound_p (TREE_TYPE (range_expr))) /* Can't bind a reference to an array of runtime bound. */ range_temp = range_expr; @@ -28091,7 +28091,7 @@ cp_parser_oacc_data_clause_deviceptr (cp_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) ; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ad2970d5822..874f29f02c6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2455,7 +2455,7 @@ check_explicit_specialization (tree declarator, switch (tsk) { case tsk_none: - if (processing_specialization && TREE_CODE (decl) != VAR_DECL) + if (processing_specialization && !VAR_P (decl)) { specialization = 1; SET_DECL_TEMPLATE_SPECIALIZATION (decl); @@ -2888,7 +2888,7 @@ check_explicit_specialization (tree declarator, /* A specialization is not necessarily COMDAT. */ DECL_COMDAT (decl) = (TREE_PUBLIC (decl) && DECL_DECLARED_INLINE_P (decl)); - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) DECL_COMDAT (decl) = false; /* Register this specialization so that we can find it @@ -4771,7 +4771,7 @@ push_template_decl_real (tree decl, bool is_friend) is_partial = ((DECL_IMPLICIT_TYPEDEF_P (decl) && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE && CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl))) - || (TREE_CODE (decl) == VAR_DECL + || (VAR_P (decl) && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_SPECIALIZATION (decl) && TINFO_USED_TEMPLATE_ID (DECL_TEMPLATE_INFO (decl)))); @@ -10792,7 +10792,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (PRIMARY_TEMPLATE_P (t)) DECL_PRIMARY_TEMPLATE (r) = r; - if (TREE_CODE (decl) != TYPE_DECL && TREE_CODE (decl) != VAR_DECL) + if (TREE_CODE (decl) != TYPE_DECL && !VAR_P (decl)) /* Record this non-type partial instantiation. */ register_specialization (r, t, DECL_TI_ARGS (DECL_TEMPLATE_RESULT (r)), diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2f3303a96fb..6a746483211 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3161,7 +3161,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain) = decl_function_context (containing_function); } - if (lambda_expr && TREE_CODE (decl) == VAR_DECL + if (lambda_expr && VAR_P (decl) && DECL_ANON_UNION_VAR_P (decl)) { if (complain & tf_error) @@ -4281,7 +4281,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, return error_mark_node; if (type_dependent_expression_p (t)) return NULL_TREE; - if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL) + if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { if (processing_template_decl) return NULL_TREE; @@ -4296,7 +4296,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &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, @@ -5662,7 +5662,7 @@ 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) { if (processing_template_decl) break; @@ -5732,7 +5732,7 @@ 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) { if (processing_template_decl) break; @@ -5774,7 +5774,7 @@ 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) { if (processing_template_decl) break; @@ -5789,7 +5789,7 @@ finish_omp_clauses (tree clauses) 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 ("%qD is threadprivate variable in %qs clause", t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9ee203fcadd..272fb2c99b2 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3683,8 +3683,7 @@ handle_abi_tag_attribute (tree* node, tree name, tree args, } else { - if (TREE_CODE (*node) != FUNCTION_DECL - && TREE_CODE (*node) != VAR_DECL) + if (!VAR_OR_FUNCTION_DECL_P (*node)) { error ("%qE attribute applied to non-function, non-variable %qD", name, *node); diff --git a/gcc/cp/vtable-class-hierarchy.c b/gcc/cp/vtable-class-hierarchy.c index a1582e77e82..2c59f14f389 100644 --- a/gcc/cp/vtable-class-hierarchy.c +++ b/gcc/cp/vtable-class-hierarchy.c @@ -557,11 +557,11 @@ register_construction_vtables (tree base_class, tree record_type, if (TREE_OPERAND (value, 0)) val_vtbl_decl = TREE_OPERAND (value, 0); - while (TREE_CODE (val_vtbl_decl) != VAR_DECL + while (!VAR_P (val_vtbl_decl) && TREE_OPERAND (val_vtbl_decl, 0)) val_vtbl_decl = TREE_OPERAND (val_vtbl_decl, 0); - gcc_assert (TREE_CODE (val_vtbl_decl) == VAR_DECL); + gcc_assert (VAR_P (val_vtbl_decl)); /* Check to see if we already have this vtable pointer in our valid set for this base class. */ @@ -876,7 +876,7 @@ output_set_info (tree record_type, vec vtbl_ptr_array) if (TREE_CODE (arg0) == ADDR_EXPR) arg0 = TREE_OPERAND (arg0, 0); - if (TREE_CODE (arg0) == VAR_DECL) + if (VAR_P (arg0)) vptr_name = IDENTIFIER_POINTER (DECL_NAME (arg0)); if (TREE_CODE (arg1) == INTEGER_CST) -- 2.30.2