On October 8, 2016 9:11:22 PM GMT+02:00, Jakub Jelinek <ja...@redhat.com> wrote:
>Hi!
>
>This patch changes various TREE_CODE (xyz) == VAR_DECL into VAR_P
>(xyz),
>TREE_CODE (xyz) != VAR_DECL into !VAR_P (xyz) and
>TREE_CODE (xyz) == VAR_DECL || TREE_CODE (xyz) == FUNCTION_DECL
>into VAR_OR_FUNCTION_DECL_P (xyz).
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

>2016-10-08  Jakub Jelinek  <ja...@redhat.com>
>
>       * tree-ssa.c (target_for_debug_bind, verify_phi_args,
>       ssa_undefined_value_p, maybe_optimize_var): Use VAR_P and/or
>       VAR_OR_FUNCTION_DECL_P macros.
>       * tree-chkp.c (chkp_register_var_initializer, chkp_make_static_bounds,
>       chkp_get_bounds_for_decl_addr, chkp_parse_array_and_component_ref,
>       chkp_find_bounds_1): Likewise.
>       * ipa-polymorphic-call.c (decl_maybe_in_construction_p): Likewise.
>       * hsa-gen.c (get_symbol_for_decl): Likewise.
>       * cgraphunit.c (check_global_declaration, analyze_functions,
>       handle_alias_pairs, thunk_adjust, cgraph_node::expand_thunk):
>       Likewise.
>       * gimple-fold.c (can_refer_decl_in_current_unit_p,
>       canonicalize_constructor_val, gimple_get_virt_method_for_vtable):
>       Likewise.
>       * tree.c (set_decl_section_name, copy_node_stat,
>       need_assembler_name_p, free_lang_data_in_decl, find_decls_types_r,
>       merge_dllimport_decl_attributes, handle_dll_attribute,
>       decl_init_priority_insert, auto_var_in_fn_p, array_at_struct_end_p,
>       verify_type): Likewise.
>       * gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior,
>       find_explicit_erroneous_behavior): Likewise.
>       * sdbout.c (sdbout_toplevel_data, sdbout_late_global_decl): Likewise.
>       * ipa.c (process_references): Likewise.
>       * tree-chkp-opt.c (chkp_get_check_result): Likewise.
>       * varasm.c (get_block_for_decl, use_blocks_for_decl_p, make_decl_rtl,
>       notice_global_symbol, assemble_variable, mark_decl_referenced,
>       build_constant_desc, output_constant_def_contents, do_assemble_alias,
>       make_decl_one_only, default_section_type_flags,
>       categorize_decl_for_section, default_encode_section_info): Likewise.
>       * trans-mem.c (requires_barrier): Likewise.
>       * gimple-expr.c (mark_addressable): Likewise.
>       * cfgexpand.c (add_scope_conflicts_1, expand_one_var,
>       expand_used_vars_for_block, clear_tree_used, stack_protect_decl_p,
>       expand_debug_expr): Likewise.
>       * tree-dump.c (dequeue_and_dump): Likewise.
>       * ubsan.c (instrument_bool_enum_load): Likewise.
>       * tree-pretty-print.c (print_declaration): Likewise.
>       * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise.
>       * tree-ssa-uninit.c (warn_uninitialized_vars): Likewise.
>       * asan.c (asan_protect_global, instrument_derefs): Likewise.
>       * tree-into-ssa.c (rewrite_stmt, maybe_register_def,
>       pass_build_ssa::execute): Likewise.
>       * var-tracking.c (var_debug_decl, track_expr_p): Likewise.
>       * tree-ssa-loop-ivopts.c (force_expr_to_var_cost, split_address_cost):
>       Likewise.
>       * ipa-split.c (test_nonssa_use, consider_split, mark_nonssa_use):
>       Likewise.
>       * tree-inline.c (insert_debug_decl_map, remap_ssa_name,
>       can_be_nonlocal, remap_decls, copy_debug_stmt,
>       initialize_inlined_parameters, add_local_variables,
>       reset_debug_binding, replace_locals_op): Likewise.
>       * dse.c (can_escape): Likewise.
>       * ipa-devirt.c (compare_virtual_tables, referenced_from_vtable_p):
>       Likewise.
>       * tree-diagnostic.c (default_tree_printer): Likewise.
>       * tree-streamer-in.c (unpack_ts_decl_common_value_fields,
>       unpack_ts_decl_with_vis_value_fields,
>       lto_input_ts_decl_common_tree_pointers): Likewise.
>       * builtins.c (builtin_save_expr, fold_builtin_expect,
>       readonly_data_expr): Likewise.
>       * tree-ssa-structalias.c (new_var_info, get_constraint_for_ssa_var,
>       create_variable_info_for, set_uids_in_ptset, visit_loadstore):
>       Likewise.
>       * gimple-streamer-out.c (output_gimple_stmt): Likewise.
>       * gimplify.c (force_constant_size, gimplify_bind_expr,
>       gimplify_decl_expr, gimplify_var_or_parm_decl,
>       gimplify_compound_lval, gimplify_init_constructor,
>       gimplify_modify_expr, gimplify_asm_expr, gimplify_oacc_declare,
>       gimplify_type_sizes): Likewise.
>       * cgraphbuild.c (record_reference, record_type_list, mark_address,
>       mark_load, mark_store, pass_build_cgraph_edges::execute): Likewise.
>       * tree-ssa-live.c (mark_all_vars_used_1, remove_unused_scope_block_p,
>       remove_unused_locals): Likewise.
>       * tree-ssa-alias.c (ptr_deref_may_alias_decl_p, ptrs_compare_unequal,
>       ref_maybe_used_by_call_p_1, call_may_clobber_ref_p_1): Likewise.
>       * function.c (instantiate_expr, instantiate_decls_1,
>       setjmp_vars_warning, add_local_decl): Likewise.
>       * alias.c (ao_ref_from_mem, get_alias_set, compare_base_symbol_refs):
>       Likewise.
>       * tree-stdarg.c (find_va_list_reference, va_list_counter_struct_op,
>       va_list_ptr_read, va_list_ptr_write, check_all_va_list_escapes,
>       optimize_va_list_gpr_fpr_size): Likewise.
>       * tree-nrv.c (pass_nrv::execute): Likewise.
>       * tsan.c (instrument_expr): Likewise.
>       * tree-ssa-dce.c (remove_dead_stmt): Likewise.
>       * vtable-verify.c (verify_bb_vtables): Likewise.
>       * tree-dfa.c (ssa_default_def, set_ssa_default_def,
>       get_ref_base_and_extent): Likewise.
>       * toplev.c (wrapup_global_declaration_1, wrapup_global_declaration_2):
>       Likewise.
>       * tree-sra.c (static bool constant_decl_p, find_var_candidates,
>       analyze_all_variable_accesses): Likewise.
>       * tree-nested.c (get_nonlocal_debug_decl,
>       convert_nonlocal_omp_clauses, note_nonlocal_vla_type,
>       note_nonlocal_block_vlas, convert_nonlocal_reference_stmt,
>       get_local_debug_decl, convert_local_omp_clauses,
>       convert_local_reference_stmt, nesting_copy_decl, remap_vla_decls):
>       Likewise.
>       * tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Likewise.
>       * stmt.c (decl_overlaps_hard_reg_set_p): Likewise.
>       * dbxout.c (dbxout_late_global_decl, dbxout_type_fields,
>       dbxout_symbol, dbxout_common_check): Likewise.
>       * expr.c (expand_assignment, expand_expr_real_2, expand_expr_real_1,
>       string_constant): Likewise.
>       * hsa.c (hsa_get_declaration_name): Likewise.
>       * passes.c (rest_of_decl_compilation): Likewise.
>       * tree-ssanames.c (make_ssa_name_fn): Likewise.
>       * tree-streamer-out.c (pack_ts_decl_common_value_fields,
>       pack_ts_decl_with_vis_value_fields,
>       write_ts_decl_common_tree_pointers): Likewise.
>       * stor-layout.c (place_field): Likewise.
>       * symtab.c (symtab_node::maybe_create_reference,
>       symtab_node::verify_base, symtab_node::make_decl_local,
>       symtab_node::copy_visibility_from,
>       symtab_node::can_increase_alignment_p): Likewise.
>       * dwarf2out.c (add_var_loc_to_decl, tls_mem_loc_descriptor,
>       decl_by_reference_p, reference_to_unused, rtl_for_decl_location,
>       fortran_common, add_location_or_const_value_attribute,
>       add_scalar_info, add_linkage_name, set_block_abstract_flags,
>       local_function_static, gen_variable_die, dwarf2out_late_global_decl,
>       optimize_one_addr_into_implicit_ptr,
>       optimize_location_into_implicit_ptr): Likewise.
>       * gimple-low.c (record_vars_into): Likewise.
>       * ipa-visibility.c (update_vtable_references): Likewise.
>       * tree-ssa-address.c (fixed_address_object_p, copy_ref_info):
>       Likewise.
>       * lto-streamer-out.c (tree_is_indexable, get_symbol_initial_value,
>       DFS::DFS_write_tree_body, write_symbol): Likewise.
>       * langhooks.c (lhd_warn_unused_global_decl,
>       lhd_set_decl_assembler_name): Likewise.
>       * attribs.c (decl_attributes): Likewise.
>       * except.c (output_ttype): Likewise.
>       * varpool.c (varpool_node::get_create, ctor_for_folding,
>       varpool_node::assemble_decl, varpool_node::create_alias): Likewise.
>       * fold-const.c (fold_unary_loc): Likewise.
>       * ipa-prop.c (ipa_compute_jump_functions_for_edge,
>       ipa_find_agg_cst_from_init): Likewise.
>       * omp-low.c (expand_omp_regimplify_p, expand_omp_taskreg,
>       expand_omp_target, lower_omp_regimplify_p,
>       grid_reg_assignment_to_local_var_p, grid_remap_prebody_decls,
>       find_link_var_op): Likewise.
>       * tree-chrec.c (chrec_contains_symbols): Likewise.
>       * tree-cfg.c (verify_address, verify_expr, verify_expr_location_1,
>       gimple_duplicate_bb, move_stmt_op, replace_block_vars_by_duplicates,
>       execute_fixup_cfg): Likewise.
>
>--- gcc/tree-ssa.c.jj  2016-10-07 21:36:01.775423576 +0200
>+++ gcc/tree-ssa.c     2016-10-08 18:45:22.732284375 +0200
>@@ -246,8 +246,7 @@ target_for_debug_bind (tree var)
>       return NULL_TREE;
>     }
> 
>-  if ((TREE_CODE (var) != VAR_DECL
>-       || VAR_DECL_IS_VIRTUAL_OPERAND (var))
>+  if ((!VAR_P (var) || VAR_DECL_IS_VIRTUAL_OPERAND (var))
>       && TREE_CODE (var) != PARM_DECL)
>     return NULL_TREE;
> 
>@@ -974,7 +973,7 @@ verify_phi_args (gphi *phi, basic_block
>         tree base = TREE_OPERAND (op, 0);
>         while (handled_component_p (base))
>           base = TREE_OPERAND (base, 0);
>-        if ((TREE_CODE (base) == VAR_DECL
>+        if ((VAR_P (base)
>              || TREE_CODE (base) == PARM_DECL
>              || TREE_CODE (base) == RESULT_DECL)
>             && !TREE_ADDRESSABLE (base))
>@@ -1246,7 +1245,7 @@ ssa_undefined_value_p (tree t, bool part
>   else if (TREE_CODE (var) == RESULT_DECL && DECL_BY_REFERENCE (var))
>     return false;
> /* Hard register variables get their initial value from the ether.  */
>-  else if (TREE_CODE (var) == VAR_DECL && DECL_HARD_REGISTER (var))
>+  else if (VAR_P (var) && DECL_HARD_REGISTER (var))
>     return false;
> 
>   /* The value is undefined iff its definition statement is empty.  */
>@@ -1538,7 +1537,7 @@ maybe_optimize_var (tree var, bitmap add
>       && (TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE
>         || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE)
>       && !TREE_THIS_VOLATILE (var)
>-      && (TREE_CODE (var) != VAR_DECL || !DECL_HARD_REGISTER (var)))
>+      && (!VAR_P (var) || !DECL_HARD_REGISTER (var)))
>     {
>       DECL_GIMPLE_REG_P (var) = 1;
>       bitmap_set_bit (suitable_for_renaming, DECL_UID (var));
>--- gcc/tree-chkp.c.jj 2016-08-06 12:11:47.074554628 +0200
>+++ gcc/tree-chkp.c    2016-10-08 18:40:28.256977151 +0200
>@@ -1002,7 +1002,7 @@ chkp_register_var_initializer (tree var)
>       || DECL_INITIAL (var) == error_mark_node)
>     return false;
> 
>-  gcc_assert (TREE_CODE (var) == VAR_DECL);
>+  gcc_assert (VAR_P (var));
>   gcc_assert (DECL_INITIAL (var));
> 
>   if (TREE_STATIC (var)
>@@ -2936,7 +2936,7 @@ chkp_make_static_bounds (tree obj)
>        chkp_static_var_bounds map.  It allows to
>        avoid duplicating bound vars for decls
>        sharing assembler name.  */
>-      if (TREE_CODE (obj) == VAR_DECL)
>+      if (VAR_P (obj))
>       {
>         tree name = DECL_ASSEMBLER_NAME (obj);
>         slot = chkp_static_var_bounds->get (name);
>@@ -2952,7 +2952,7 @@ chkp_make_static_bounds (tree obj)
>     }
> 
>   /* Build decl for bounds var.  */
>-  if (TREE_CODE (obj) == VAR_DECL)
>+  if (VAR_P (obj))
>     {
>       if (DECL_IGNORED_P (obj))
>       {
>@@ -3014,7 +3014,7 @@ chkp_make_static_bounds (tree obj)
>   if (!chkp_static_var_bounds)
>     chkp_static_var_bounds = new hash_map<tree, tree>;
> 
>-  if (TREE_CODE (obj) == VAR_DECL)
>+  if (VAR_P (obj))
>     {
>       tree name = DECL_ASSEMBLER_NAME (obj);
>       chkp_static_var_bounds->put (name, bnd_var);
>@@ -3117,7 +3117,7 @@ chkp_get_bounds_for_decl_addr (tree decl
> {
>   tree bounds;
> 
>-  gcc_assert (TREE_CODE (decl) == VAR_DECL
>+  gcc_assert (VAR_P (decl)
>             || TREE_CODE (decl) == PARM_DECL
>             || TREE_CODE (decl) == RESULT_DECL);
> 
>@@ -3144,7 +3144,7 @@ chkp_get_bounds_for_decl_addr (tree decl
>       return chkp_get_zero_bounds ();
> 
>   if (flag_chkp_use_static_bounds
>-      && TREE_CODE (decl) == VAR_DECL
>+      && VAR_P (decl)
>       && (TREE_STATIC (decl)
>             || DECL_EXTERNAL (decl)
>             || TREE_PUBLIC (decl))
>@@ -3164,7 +3164,7 @@ chkp_get_bounds_for_decl_addr (tree decl
>             || DECL_EXTERNAL (decl)
>             || TREE_PUBLIC (decl))))
>     {
>-      gcc_assert (TREE_CODE (decl) == VAR_DECL);
>+      gcc_assert (VAR_P (decl));
>       bounds = chkp_generate_extern_var_bounds (decl);
>     }
>   else
>@@ -3399,7 +3399,7 @@ chkp_parse_array_and_component_ref (tree
>     }
>   else
>     {
>-      gcc_assert (TREE_CODE (var) == VAR_DECL
>+      gcc_assert (VAR_P (var)
>                 || TREE_CODE (var) == PARM_DECL
>                 || TREE_CODE (var) == RESULT_DECL
>                 || TREE_CODE (var) == STRING_CST
>@@ -3562,7 +3562,7 @@ chkp_find_bounds_1 (tree ptr, tree ptr_s
>     case MEM_REF:
>     case VAR_DECL:
>       if (BOUNDED_P (ptr_src))
>-      if (TREE_CODE (ptr) == VAR_DECL && DECL_REGISTER (ptr))
>+      if (VAR_P (ptr) && DECL_REGISTER (ptr))
>         bounds = chkp_get_zero_bounds ();
>       else
>         {
>@@ -3581,7 +3581,7 @@ chkp_find_bounds_1 (tree ptr, tree ptr_s
>         || TREE_CODE (addr) == TARGET_MEM_REF)
>       {
>         if (BOUNDED_P (ptr_src))
>-          if (TREE_CODE (ptr) == VAR_DECL && DECL_REGISTER (ptr))
>+          if (VAR_P (ptr) && DECL_REGISTER (ptr))
>             bounds = chkp_get_zero_bounds ();
>           else
>             {
>--- gcc/ipa-polymorphic-call.c.jj      2016-08-10 00:21:07.097351508 +0200
>+++ gcc/ipa-polymorphic-call.c 2016-10-08 18:30:45.042297763 +0200
>@@ -575,7 +575,7 @@ decl_maybe_in_construction_p (tree base,
>         return true;
>       }
> 
>-  if (!base || (TREE_CODE (base) == VAR_DECL && is_global_var (base)))
>+  if (!base || (VAR_P (base) && is_global_var (base)))
>     {
>       if (TREE_CODE (TREE_TYPE (function)) != METHOD_TYPE
>         || (!DECL_CXX_CONSTRUCTOR_P (function)
>--- gcc/hsa-gen.c.jj   2016-09-23 09:33:36.752328278 +0200
>+++ gcc/hsa-gen.c      2016-10-08 18:30:13.720691207 +0200
>@@ -883,12 +883,11 @@ get_symbol_for_decl (tree decl)
> 
>   gcc_assert (TREE_CODE (decl) == PARM_DECL
>             || TREE_CODE (decl) == RESULT_DECL
>-            || TREE_CODE (decl) == VAR_DECL);
>+            || VAR_P (decl));
> 
>   dummy.m_decl = decl;
> 
>-  bool is_in_global_vars
>-    = TREE_CODE (decl) == VAR_DECL && is_global_var (decl);
>+  bool is_in_global_vars = VAR_P (decl) && is_global_var (decl);
> 
>   if (is_in_global_vars)
>     slot = hsa_global_variable_symbols->find_slot (&dummy, INSERT);
>@@ -925,7 +924,7 @@ get_symbol_for_decl (tree decl)
>   else
>     {
>       hsa_symbol *sym;
>-      gcc_assert (TREE_CODE (decl) == VAR_DECL);
>+      gcc_assert (VAR_P (decl));
>       BrigAlignment8_t align = hsa_object_alignment (decl);
> 
>       if (is_in_global_vars)
>@@ -952,7 +951,7 @@ get_symbol_for_decl (tree decl)
>           align = MAX ((BrigAlignment8_t) BRIG_ALIGNMENT_8, align);
> 
>         /* PARM_DECL and RESULT_DECL should be already in m_local_symbols. 
>*/
>-        gcc_assert (TREE_CODE (decl) == VAR_DECL);
>+        gcc_assert (VAR_P (decl));
> 
>         sym = new hsa_symbol (BRIG_TYPE_NONE, BRIG_SEGMENT_PRIVATE,
>                               BRIG_LINKAGE_FUNCTION);
>--- gcc/cgraphunit.c.jj        2016-09-26 12:06:38.606878025 +0200
>+++ gcc/cgraphunit.c   2016-10-08 18:23:20.765878503 +0200
>@@ -662,7 +662,7 @@ symbol_table::process_same_body_aliases
>   FOR_EACH_SYMBOL (node)
>     if (node->cpp_implicit_alias && !node->analyzed)
>       node->resolve_alias
>-      (TREE_CODE (node->alias_target) == VAR_DECL
>+      (VAR_P (node->alias_target)
>        ? (symtab_node *)varpool_node::get_create (node->alias_target)
>        : (symtab_node *)cgraph_node::get_create (node->alias_target));
>   cpp_implicit_aliases_done = true;
>@@ -950,7 +950,7 @@ check_global_declaration (symtab_node *s
>                       && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
>                       && filename_cmp (main_input_filename,
>                                        decl_file) == 0))))
>-         && TREE_CODE (decl) == VAR_DECL))
>+         && VAR_P (decl)))
>       && ! DECL_IN_SYSTEM_HEADER (decl)
>       && ! snode->referred_to_p (/*include_self=*/false)
>       /* This TREE_USED check is needed in addition to referred_to_p
>@@ -967,7 +967,7 @@ check_global_declaration (symtab_node *s
>      /* A volatile variable might be used in some non-obvious way.  */
>       && (! VAR_P (decl) || ! TREE_THIS_VOLATILE (decl))
>     /* Global register variables must be declared to reserve them.  */
>-      && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
>+      && ! (VAR_P (decl) && DECL_REGISTER (decl))
>       /* Global ctors and dtors are called by the runtime.  */
>       && (TREE_CODE (decl) != FUNCTION_DECL
>         || (!DECL_STATIC_CONSTRUCTOR (decl)
>@@ -1194,7 +1194,7 @@ analyze_functions (bool first_time)
>            at looking at optimized away DECLs, since
>            late_global_decl will subsequently be called from the
>            contents of the now pruned symbol table.  */
>-        if (TREE_CODE (node->decl) == VAR_DECL
>+        if (VAR_P (node->decl)
>             && !decl_function_context (node->decl))
>           {
>             /* We are reclaiming totally unreachable code and variables
>@@ -1305,7 +1305,7 @@ handle_alias_pairs (void)
>         cgraph_node::create_alias (p->decl, target_node->decl);
>         alias_pairs->unordered_remove (i);
>       }
>-      else if (TREE_CODE (p->decl) == VAR_DECL
>+      else if (VAR_P (p->decl)
>              && target_node && is_a <varpool_node *> (target_node))
>       {
>         varpool_node::create_alias (p->decl, target_node->decl);
>@@ -1559,7 +1559,7 @@ thunk_adjust (gimple_stmt_iterator * bsi
>     {
>       tree ptrtmp;
> 
>-      if (TREE_CODE (ptr) == VAR_DECL)
>+      if (VAR_P (ptr))
>         ptrtmp = ptr;
>       else
>         {
>@@ -1738,7 +1738,7 @@ cgraph_node::expand_thunk (bool output_a
>               {
>                 restmp = resdecl;
> 
>-                if (TREE_CODE (restmp) == VAR_DECL)
>+                if (VAR_P (restmp))
>                   add_local_decl (cfun, restmp);
>                 BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp;
>               }
>--- gcc/gimple-fold.c.jj       2016-10-05 17:01:34.831595012 +0200
>+++ gcc/gimple-fold.c  2016-10-08 18:28:22.955082580 +0200
>@@ -105,7 +105,7 @@ can_refer_decl_in_current_unit_p (tree d
> 
> /* We are concerned only about static/external vars and functions.  */
>   if ((!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
>-      || (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) !=
>FUNCTION_DECL))
>+      || !VAR_OR_FUNCTION_DECL_P (decl))
>     return true;
> 
>/* Static objects can be referred only if they was not optimized out
>yet.  */
>@@ -126,7 +126,7 @@ can_refer_decl_in_current_unit_p (tree d
>      So we are concerned only when DECL comes from initializer of
>      external var or var that has been optimized out.  */
>   if (!from_decl
>-      || TREE_CODE (from_decl) != VAR_DECL
>+      || !VAR_P (from_decl)
>       || (!DECL_EXTERNAL (from_decl)
>         && (vnode = varpool_node::get (from_decl)) != NULL
>         && vnode->definition)
>@@ -206,13 +206,12 @@ canonicalize_constructor_val (tree cval,
>       if (!base)
>       return NULL_TREE;
> 
>-      if ((TREE_CODE (base) == VAR_DECL
>-         || TREE_CODE (base) == FUNCTION_DECL)
>+      if (VAR_OR_FUNCTION_DECL_P (base)
>         && !can_refer_decl_in_current_unit_p (base, from_decl))
>       return NULL_TREE;
>       if (TREE_TYPE (base) == error_mark_node)
>       return NULL_TREE;
>-      if (TREE_CODE (base) == VAR_DECL)
>+      if (VAR_P (base))
>       TREE_ADDRESSABLE (base) = 1;
>       else if (TREE_CODE (base) == FUNCTION_DECL)
>       {
>@@ -6057,8 +6056,7 @@ gimple_get_virt_method_for_vtable (HOST_
>     *can_refer = true;
> 
>   /* First of all double check we have virtual table.  */
>-  if (TREE_CODE (v) != VAR_DECL
>-      || !DECL_VIRTUAL_P (v))
>+  if (!VAR_P (v) || !DECL_VIRTUAL_P (v))
>     {
>       /* Pass down that we lost track of the target.  */
>       if (can_refer)
>--- gcc/tree.c.jj      2016-08-29 12:17:13.369684226 +0200
>+++ gcc/tree.c 2016-10-08 18:39:26.322753817 +0200
>@@ -716,7 +716,7 @@ set_decl_section_name (tree node, const
>       if (!snode)
>       return;
>     }
>-  else if (TREE_CODE (node) == VAR_DECL)
>+  else if (VAR_P (node))
>     snode = varpool_node::get_create (node);
>   else
>     snode = cgraph_node::get_create (node);
>@@ -1156,19 +1156,19 @@ copy_node_stat (tree node MEM_STAT_DECL)
>         if (DECL_PT_UID_SET_P (node))
>           SET_DECL_PT_UID (t, DECL_PT_UID (node));
>       }
>-      if ((TREE_CODE (node) == PARM_DECL || TREE_CODE (node) ==
>VAR_DECL)
>+      if ((TREE_CODE (node) == PARM_DECL || VAR_P (node))
>         && DECL_HAS_VALUE_EXPR_P (node))
>       {
>         SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node));
>         DECL_HAS_VALUE_EXPR_P (t) = 1;
>       }
>       /* DECL_DEBUG_EXPR is copied explicitely by callers.  */
>-      if (TREE_CODE (node) == VAR_DECL)
>+      if (VAR_P (node))
>       {
>         DECL_HAS_DEBUG_EXPR_P (t) = 0;
>         t->decl_with_vis.symtab_node = NULL;
>       }
>-      if (TREE_CODE (node) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P
>(node))
>+      if (VAR_P (node) && DECL_HAS_INIT_PRIORITY_P (node))
>       {
>         SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node));
>         DECL_HAS_INIT_PRIORITY_P (t) = 1;
>@@ -5330,8 +5330,7 @@ need_assembler_name_p (tree decl)
>       && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
>     return !DECL_ASSEMBLER_NAME_SET_P (decl);
>   /* Only FUNCTION_DECLs and VAR_DECLs are considered.  */
>-  if (TREE_CODE (decl) != FUNCTION_DECL
>-      && TREE_CODE (decl) != VAR_DECL)
>+  if (!VAR_OR_FUNCTION_DECL_P (decl))
>     return false;
> 
>   /* If DECL already has its assembler name set, it does not need a
>@@ -5346,7 +5345,7 @@ need_assembler_name_p (tree decl)
> 
>   /* For VAR_DECLs, only static, public and external symbols need an
>      assembler name.  */
>-  if (TREE_CODE (decl) == VAR_DECL
>+  if (VAR_P (decl)
>       && !TREE_STATIC (decl)
>       && !TREE_PUBLIC (decl)
>       && !DECL_EXTERNAL (decl))
>@@ -5460,7 +5459,7 @@ free_lang_data_in_decl (tree decl)
>      if (DECL_VINDEX (decl) && !tree_fits_shwi_p (DECL_VINDEX (decl)))
>       DECL_VINDEX (decl) = NULL_TREE;
>     }
>-  else if (TREE_CODE (decl) == VAR_DECL)
>+  else if (VAR_P (decl))
>     {
>       if ((DECL_EXTERNAL (decl)
>          && (!TREE_STATIC (decl) || !TREE_READONLY (decl)))
>@@ -5632,7 +5631,7 @@ find_decls_types_r (tree *tp, int *ws, v
>         fld_worklist_push (DECL_FCONTEXT (t), fld);
>       }
> 
>-      if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL)
>+      if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL)
>         && DECL_HAS_VALUE_EXPR_P (t))
>       fld_worklist_push (DECL_VALUE_EXPR (t), fld);
> 
>@@ -6329,14 +6328,13 @@ merge_dllimport_decl_attributes (tree ol
>             decl may already have had TREE_CONSTANT computed.
>             We still remove the attribute so that assembler code refers
>             to '&foo rather than '_imp__foo'.  */
>-        if (TREE_CODE (old) == VAR_DECL && TREE_ADDRESSABLE (old))
>+        if (VAR_P (old) && TREE_ADDRESSABLE (old))
>           DECL_DLLIMPORT_P (new_tree) = 1;
>       }
> 
>  /* Let an inline definition silently override the external reference,
>        but otherwise warn about attribute inconsistency.  */
>-      else if (TREE_CODE (new_tree) == VAR_DECL
>-             || !DECL_DECLARED_INLINE_P (new_tree))
>+      else if (VAR_P (new_tree) || !DECL_DECLARED_INLINE_P (new_tree))
>       warning (OPT_Wattributes, "%q+D redeclared without dllimport
>attribute: "
>                 "previous dllimport ignored", new_tree);
>     }
>@@ -6387,9 +6385,7 @@ handle_dll_attribute (tree * pnode, tree
>       }
>     }
> 
>-  if (TREE_CODE (node) != FUNCTION_DECL
>-      && TREE_CODE (node) != VAR_DECL
>-      && TREE_CODE (node) != TYPE_DECL)
>+  if (!VAR_OR_FUNCTION_DECL_P (node) && TREE_CODE (node) != TYPE_DECL)
>     {
>       *no_add_attrs = true;
>       warning (OPT_Wattributes, "%qE attribute ignored",
>@@ -6432,7 +6428,7 @@ handle_dll_attribute (tree * pnode, tree
>         *no_add_attrs = true;
>       }
> 
>-     else if (TREE_CODE (node) == VAR_DECL)
>+     else if (VAR_P (node))
>       {
>         if (DECL_INITIAL (node))
>           {
>@@ -6460,9 +6456,7 @@ handle_dll_attribute (tree * pnode, tree
>     DECL_EXTERNAL (node) = 0;
> 
>   /*  Report error if symbol is not accessible at global scope.  */
>-  if (!TREE_PUBLIC (node)
>-      && (TREE_CODE (node) == VAR_DECL
>-        || TREE_CODE (node) == FUNCTION_DECL))
>+  if (!TREE_PUBLIC (node) && VAR_OR_FUNCTION_DECL_P (node))
>     {
>       error ("external linkage required for symbol %q+D because of "
>            "%qE attribute", node, name);
>@@ -6822,7 +6816,7 @@ decl_init_priority_insert (tree decl, pr
>       if (!snode)
>       return;
>     }
>-  else if (TREE_CODE (decl) == VAR_DECL)
>+  else if (VAR_P (decl))
>     snode = varpool_node::get_create (decl);
>   else
>     snode = cgraph_node::get_create (decl);
>@@ -9196,7 +9190,7 @@ bool
> auto_var_in_fn_p (const_tree var, const_tree fn)
> {
>   return (DECL_P (var) && DECL_CONTEXT (var) == fn
>-        && ((((TREE_CODE (var) == VAR_DECL && ! DECL_EXTERNAL (var))
>+        && ((((VAR_P (var) && ! DECL_EXTERNAL (var))
>               || TREE_CODE (var) == PARM_DECL)
>              && ! TREE_STATIC (var))
>             || TREE_CODE (var) == LABEL_DECL
>@@ -13139,7 +13133,7 @@ array_at_struct_end_p (tree ref)
>       && (!size || (DECL_SIZE (ref) != NULL
>                   && operand_equal_p (DECL_SIZE (ref), size, 0)))
>       && !(flag_unconstrained_commons
>-         && TREE_CODE (ref) == VAR_DECL && DECL_COMMON (ref)))
>+         && VAR_P (ref) && DECL_COMMON (ref)))
>     return false;
> 
>   return true;
>@@ -13971,7 +13965,7 @@ verify_type (const_tree t)
>           ;
>         else if (TREE_CODE (fld) == CONST_DECL)
>           ;
>-        else if (TREE_CODE (fld) == VAR_DECL)
>+        else if (VAR_P (fld))
>           ;
>         else if (TREE_CODE (fld) == TEMPLATE_DECL)
>           ;
>--- gcc/gimple-ssa-isolate-paths.c.jj  2016-02-12 00:50:55.792885920
>+0100
>+++ gcc/gimple-ssa-isolate-paths.c     2016-10-08 18:28:49.427750046 +0200
>@@ -268,8 +268,7 @@ find_implicit_erroneous_behavior (void)
>             if (TREE_CODE (op) == ADDR_EXPR)
>               {
>                 tree valbase = get_base_address (TREE_OPERAND (op, 0));
>-                if ((TREE_CODE (valbase) == VAR_DECL
>-                     && !is_global_var (valbase))
>+                if ((VAR_P (valbase) && !is_global_var (valbase))
>                     || TREE_CODE (valbase) == PARM_DECL)
>                   {
>                     FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
>@@ -426,8 +425,7 @@ find_explicit_erroneous_behavior (void)
>             if (val && TREE_CODE (val) == ADDR_EXPR)
>               {
>                 tree valbase = get_base_address (TREE_OPERAND (val, 0));
>-                if ((TREE_CODE (valbase) == VAR_DECL
>-                     && !is_global_var (valbase))
>+                if ((VAR_P (valbase) && !is_global_var (valbase))
>                     || TREE_CODE (valbase) == PARM_DECL)
>                   {
>                     /* We only need it for this particular case.  */
>--- gcc/sdbout.c.jj    2016-09-20 10:26:02.718767879 +0200
>+++ gcc/sdbout.c       2016-10-08 18:35:47.586497380 +0200
>@@ -906,7 +906,7 @@ sdbout_toplevel_data (tree decl)
>   if (DECL_IGNORED_P (decl))
>     return;
> 
>-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
>+  gcc_assert (VAR_P (decl));
>   gcc_assert (MEM_P (DECL_RTL (decl)));
>   gcc_assert (DECL_INITIAL (decl));
> 
>@@ -1434,9 +1434,7 @@ sdbout_early_global_decl (tree decl ATTR
> static void
> sdbout_late_global_decl (tree decl)
> {
>-  if (TREE_CODE (decl) == VAR_DECL
>-      && !DECL_EXTERNAL (decl)
>-      && DECL_RTL_SET_P (decl))
>+  if (VAR_P (decl) && !DECL_EXTERNAL (decl) && DECL_RTL_SET_P (decl))
>     {
>       /* The COFF linker can move initialized global vars to the end.
>        And that can screw up the symbol ordering.  Defer those for
>--- gcc/ipa.c.jj       2016-09-21 08:54:17.084104510 +0200
>+++ gcc/ipa.c  2016-10-08 18:30:27.114522962 +0200
>@@ -128,7 +128,7 @@ process_references (symtab_node *snode,
>                 /* We use variable constructors during late compilation for
>                    constant folding.  Keep references alive so partitioning
>                    knows about potential references.  */
>-                || (TREE_CODE (node->decl) == VAR_DECL
>+                || (VAR_P (node->decl)
>                     && flag_wpa
>                     && ctor_for_folding (node->decl)
>                        != error_mark_node))))
>--- gcc/tree-chkp-opt.c.jj     2016-09-23 18:57:51.590500469 +0200
>+++ gcc/tree-chkp-opt.c        2016-10-08 18:40:34.235902174 +0200
>@@ -610,7 +610,7 @@ chkp_get_check_result (struct check_info
>       chkp_collect_value (DECL_INITIAL (bnd_var), bound_val);
>       if (ci->type == CHECK_UPPER_BOUND)
>       {
>-        if (TREE_CODE (var) == VAR_DECL)
>+        if (VAR_P (var))
>           {
>             if (DECL_SIZE (var)
>                 && !chkp_variable_size_type (TREE_TYPE (var)))
>--- gcc/varasm.c.jj    2016-09-28 21:17:52.386301063 +0200
>+++ gcc/varasm.c       2016-10-08 18:50:24.605498828 +0200
>@@ -170,8 +170,7 @@ static GTY(()) section *unnamed_sections
> 
> /* Return a nonzero value if DECL has a section attribute.  */
> #define IN_NAMED_SECTION(DECL) \
>-  ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL)
>\
>-   && DECL_SECTION_NAME (DECL) != NULL)
>+  (VAR_OR_FUNCTION_DECL_P (DECL) && DECL_SECTION_NAME (DECL) != NULL)
> 
> struct section_hasher : ggc_ptr_hash<section>
> {
>@@ -1188,7 +1187,7 @@ get_block_for_decl (tree decl)
> {
>   section *sect;
> 
>-  if (TREE_CODE (decl) == VAR_DECL)
>+  if (VAR_P (decl))
>     {
>       /* The object must be defined in this translation unit.  */
>       if (DECL_EXTERNAL (decl))
>@@ -1209,7 +1208,7 @@ get_block_for_decl (tree decl)
> 
>  /* Find out which section should contain DECL.  We cannot put it into
>      an object block if it requires a standalone definition.  */
>-  if (TREE_CODE (decl) == VAR_DECL)
>+  if (VAR_P (decl))
>       align_variable (decl, 0);
>   sect = get_variable_section (decl, true);
>   if (SECTION_STYLE (sect) == SECTION_NOSWITCH)
>@@ -1238,7 +1237,7 @@ use_blocks_for_decl_p (tree decl)
>   struct symtab_node *snode;
> 
>   /* Only data DECLs can be placed into object blocks.  */
>-  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != CONST_DECL)
>+  if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL)
>     return false;
> 
>   /* Detect decls created by dw2_force_const_mem.  Such decls are
>@@ -1250,7 +1249,7 @@ use_blocks_for_decl_p (tree decl)
> 
>   /* If this decl is an alias, then we don't want to emit a
>      definition.  */
>-  if (TREE_CODE (decl) == VAR_DECL
>+  if (VAR_P (decl)
>       && (snode = symtab_node::get (decl)) != NULL
>       && snode->alias)
>     return false;
>@@ -1304,7 +1303,7 @@ make_decl_rtl (tree decl)
>             && TREE_CODE (decl) != RESULT_DECL);
> 
>   /* A weak alias has TREE_PUBLIC set but not the other bits.  */
>-  gcc_assert (TREE_CODE (decl) != VAR_DECL
>+  gcc_assert (!VAR_P (decl)
>             || TREE_STATIC (decl)
>             || TREE_PUBLIC (decl)
>             || DECL_EXTERNAL (decl)
>@@ -1348,7 +1347,7 @@ make_decl_rtl (tree decl)
> 
>  /* If this variable belongs to the global constant pool, retrieve the
>      pre-computed RTL or recompute it in LTO mode.  */
>-  if (TREE_CODE (decl) == VAR_DECL && DECL_IN_CONSTANT_POOL (decl))
>+  if (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
>     {
>     SET_DECL_RTL (decl, output_constant_def (DECL_INITIAL (decl), 1));
>       return;
>@@ -1457,7 +1456,7 @@ make_decl_rtl (tree decl)
>      visibility pass is doing the same work.  But notice_global_symbol
>      is called early and it needs to make DECL_RTL to get the name.
>we take care of recomputing the DECL_RTL after visibility is changed. 
>*/
>-  if (TREE_CODE (decl) == VAR_DECL
>+  if (VAR_P (decl)
>       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
>       && DECL_SECTION_NAME (decl) != NULL
>       && DECL_INITIAL (decl) == NULL_TREE
>@@ -1465,7 +1464,7 @@ make_decl_rtl (tree decl)
>     DECL_COMMON (decl) = 0;
> 
>   /* Variables can't be both common and weak.  */
>-  if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (decl))
>+  if (VAR_P (decl) && DECL_WEAK (decl))
>     DECL_COMMON (decl) = 0;
> 
>   if (use_object_blocks_p () && use_blocks_for_decl_p (decl))
>@@ -1639,9 +1638,9 @@ notice_global_symbol (tree decl)
>       || !TREE_PUBLIC (decl)
>       || DECL_EXTERNAL (decl)
>       || !DECL_NAME (decl)
>-      || (TREE_CODE (decl) == VAR_DECL && DECL_HARD_REGISTER (decl))
>+      || (VAR_P (decl) && DECL_HARD_REGISTER (decl))
>       || (TREE_CODE (decl) != FUNCTION_DECL
>-        && (TREE_CODE (decl) != VAR_DECL
>+        && (!VAR_P (decl)
>             || (DECL_COMMON (decl)
>                 && (DECL_INITIAL (decl) == 0
>                     || DECL_INITIAL (decl) == error_mark_node)))))
>@@ -2111,7 +2110,7 @@ assemble_variable (tree decl, int top_le
>   bool asan_protected = false;
> 
>/* This function is supposed to handle VARIABLES.  Ensure we have one. 
>*/
>-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
>+  gcc_assert (VAR_P (decl));
> 
>   /* Emulated TLS had better not get this far.  */
> gcc_checking_assert (targetm.have_tls || !DECL_THREAD_LOCAL_P (decl));
>@@ -2487,7 +2486,7 @@ mark_decl_referenced (tree decl)
>         && !node->definition)
>       node->mark_force_output ();
>     }
>-  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
>@@ -3272,8 +3271,7 @@ build_constant_desc (tree exp)
>   if (use_object_blocks_p ())
>     {
>       int align = (TREE_CODE (decl) == CONST_DECL
>-                 || (TREE_CODE (decl) == VAR_DECL
>-                     && DECL_IN_CONSTANT_POOL (decl))
>+                 || (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
>                  ? DECL_ALIGN (decl)
>                  : symtab_node::get (decl)->definition_alignment ());
>       section *sect = get_constant_section (exp, align);
>@@ -3430,8 +3428,7 @@ output_constant_def_contents (rtx symbol
>   else
>     {
>       int align = (TREE_CODE (dec


Reply via email to