This patch introduces the predicate VAR_P and use it in place of direct

    TREE_CODE (t) == VAR_DECL

It improves readability and makes predicates easier to follow.
Tested on an x86_64-suse-linux.  Applying to trunk.

-- Gaby

2013-03-29  Gabriel Dos Reis  <g...@integrable-solutions.net>

        * tree.h (VAR_P): New.

cp/ChangeLog
2013-03-29  Gabriel Dos Reis  <g...@integrable-solutions.net>

        * call.c (build_java_interface_fn_ref): Likewise.
        (make_temporary_var_for_ref_to_temp): Likewise.
        * class.c (check_field_decls): Likewise.
        (layout_class_type): Likewise.
        (finish_struct_1): Likewise.
        (fixed_type_or_null): Likewise.
        (get_vtbl_decl_for_binfo): Likewise.
        * cp-gimplify.c (omp_var_to_track): Likewise.
        (cp_genericize_r): Likewise.
        * cp-objcp-common.c (cxx_warn_unused_global_decl): Likewise.
        * cp-tree.h (LANG_DECL_HAS_MIN): Likewise.
        (DECL_DISCRIMINATOR_P): Likewise.
        * decl.c (poplevel): Likewise.
        (decls_match): Likewise.
        (duplicate_decls): Likewise.
        (decl_jump_unsafe): Likewise.
        (start_decl): Likewise.
        (check_for_uninitialized_const_var): Likewise.
        (make_rtl_for_nonlocal_decl): Likewise.
        (cp_finish_decl): Likewise.
        (expand_static_init): Likewise.
        (local_variable_p): Likewise.
        (maybe_register_incomplete_var): Likewise.
        * decl2.c (grokfield): Likewise.
        (comdat_linkage): Likewise.
        (determine_visibility): Likewise.
        (import_export_decl): Likewise.
        (prune_vars_needing_no_initialization): Likewise.
        (decl_maybe_constant_var_p): Likewise.
        * error.c (dump_simple_decl): Likewise.
        (dump_template_decl): Likewise.
        (cp_printer): Likewise.
        * except.c (build_throw): Likewise.
        * init.c (build_vtbl_address): Likewise.
        (member_init_ok_or_else): Likewise.
        (build_aggr_init): Likewise.
        (expand_aggr_init_1): Likewise.
        (build_offset_ref): Likewise.
        (constant_value_1): Likewise.
        * mangle.c (write_mangled_name): Likewise.
        (write_prefix): Likewise.
        * name-lookup.c (supplement_binding_1): Likewise.
        (add_decl_to_level): Likewise.
        (pushdecl_maybe_friend_1): Likewise.
        (check_for_out_of_scope_variable): Likewise.
        (validate_nonmember_using_decl): Likewise.
        (lookup_name_innermost_nonclass_level_1): Likewise.
        (lookup_arg_dependent_1): Likewise.
        * parser.c (cp_parser_lambda_introducer): Likewise.
        (cp_parser_template_argument): Likewise.
        (cp_parser_single_declaration): Likewise.
        * pt.c (convert_nontype_argument): Likewise.
        (instantiate_class_template_1): Likewise.
        (tsubst_decl): Likewise.
        (tsubst_expr): Likewise.
        (do_decl_instantiation): Likewise.
        (do_type_instantiation): Likewise.
        (regenerate_decl_from_template): Likewise.
        (always_instantiate_p): Likewise.
        (instantiate_decl): Likewise.
        (type_dependent_expression_p): Likewise.
        (build_non_dependent_expr): Likewise.
        * repo.c (repo_emit_p): Likewise.
        * rtti.c (build_dynamic_cast_1): Likewise.
        * search.c (shared_member_p): Likewise.
        * semantics.c (outer_var_p): Likewise.
        (finish_id_expression): Likewise.
        (finish_omp_clauses): Likewise.
        (finish_decltype_type): Likewise.
        (ensure_literal_type_for_constexpr_object): Likewise.
        * tree.c (lvalue_kind): Likewise.
        (bot_replace): Likewise.
        (cp_tree_equal): Likewise.
        (handle_init_priority_attribute): Likewise.
        (decl_storage_duration): Likewise.
        * typeck.c (cxx_sizeof_expr): Likewise.
        (cxx_alignof_expr): Likewise.
        (decay_conversion): Likewise.
        (build_class_member_access_expr): Likewise.
        (cp_build_array_ref): Likewise.
        (cxx_mark_addressable): Likewise.
        (maybe_warn_about_returning_address_of_local): Likewise.
        (check_return_expr): Likewise.
        * typeck2.c (cxx_readonly_error): Likewise.
        (abstract_virtuals_error_sfinae): Likewise.
        (cxx_incomplete_type_diagnostic): Likewise.

Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c       (revision 197239)
+++ gcc/cp/call.c       (working copy)
@@ -7162,7 +7162,7 @@
   /* Get the java.lang.Class pointer for the interface being called.  */
   iface = DECL_CONTEXT (fn);
   iface_ref = lookup_field (iface, get_identifier ("class$"), 0, false);
-  if (!iface_ref || TREE_CODE (iface_ref) != VAR_DECL
+  if (!iface_ref || !VAR_P (iface_ref)
       || DECL_CONTEXT (iface_ref) != iface)
     {
       error ("could not find class$ field in java interface type %qT",
@@ -9009,7 +9009,7 @@
   var = create_temporary_var (type);
 
   /* Register the variable.  */
-  if (TREE_CODE (decl) == VAR_DECL
+  if (VAR_P (decl)
       && (TREE_STATIC (decl) || DECL_THREAD_LOCAL_P (decl)))
     {
       /* Namespace-scope or local static; give it a mangled name.  */
Index: gcc/cp/class.c
===================================================================
--- gcc/cp/class.c      (revision 197239)
+++ gcc/cp/class.c      (working copy)
@@ -3327,7 +3327,7 @@
 
             If a union contains a static data member, or a member of
             reference type, the program is ill-formed.  */
-         if (TREE_CODE (x) == VAR_DECL)
+         if (VAR_P (x))
            {
              error ("%q+D may not be static because it is a member of a 
union", x);
              continue;
@@ -3359,7 +3359,7 @@
       if (type == error_mark_node)
        continue;
 
-      if (TREE_CODE (x) == CONST_DECL || TREE_CODE (x) == VAR_DECL)
+      if (TREE_CODE (x) == CONST_DECL || VAR_P (x))
        continue;
 
       /* Now it can only be a FIELD_DECL.  */
@@ -5826,7 +5826,7 @@
 
             At this point, finish_record_layout will be called, but
             S1 is still incomplete.)  */
-         if (TREE_CODE (field) == VAR_DECL)
+         if (VAR_P (field))
            {
              maybe_register_incomplete_var (field);
              /* The visibility of static data members is determined
@@ -6327,7 +6327,7 @@
   /* Complete the rtl for any static member objects of the type we're
      working on.  */
   for (x = TYPE_FIELDS (t); x; x = DECL_CHAIN (x))
-    if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x)
+    if (VAR_P (x) && TREE_STATIC (x)
         && TREE_TYPE (x) != error_mark_node
        && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t))
       DECL_MODE (x) = TYPE_MODE (t);
@@ -6700,7 +6700,7 @@
          /* Enter the INSTANCE in a table to prevent recursion; a
             variable's initializer may refer to the variable
             itself.  */
-         if (TREE_CODE (instance) == VAR_DECL
+         if (VAR_P (instance)
              && DECL_INITIAL (instance)
              && !type_dependent_expression_p_push (DECL_INITIAL (instance))
              && !fixed_type_or_null_ref_ht.find (instance))
@@ -7766,7 +7766,7 @@
       decl = TREE_OPERAND (TREE_OPERAND (decl, 0), 0);
     }
   if (decl)
-    gcc_assert (TREE_CODE (decl) == VAR_DECL);
+    gcc_assert (VAR_P (decl));
   return decl;
 }
 
Index: gcc/cp/cp-gimplify.c
===================================================================
--- gcc/cp/cp-gimplify.c        (revision 197239)
+++ gcc/cp/cp-gimplify.c        (working copy)
@@ -759,7 +759,7 @@
     type = TREE_TYPE (type);
   if (type == error_mark_node || !CLASS_TYPE_P (type))
     return false;
-  if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl))
+  if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
     return false;
   if (cxx_omp_predetermined_sharing (decl) != OMP_CLAUSE_DEFAULT_UNSPECIFIED)
     return false;
@@ -838,7 +838,7 @@
 
   /* If in an OpenMP context, note var uses.  */
   if (__builtin_expect (wtd->omp_ctx != NULL, 0)
-      && (TREE_CODE (stmt) == VAR_DECL
+      && (VAR_P (stmt)
          || TREE_CODE (stmt) == PARM_DECL
          || TREE_CODE (stmt) == RESULT_DECL)
       && omp_var_to_track (stmt))
@@ -998,7 +998,7 @@
        {
          tree decl;
          for (decl = BIND_EXPR_VARS (stmt); decl; decl = DECL_CHAIN (decl))
-           if (TREE_CODE (decl) == VAR_DECL
+           if (VAR_P (decl)
                && !DECL_EXTERNAL (decl)
                && omp_var_to_track (decl))
              {
Index: gcc/cp/cp-objcp-common.c
===================================================================
--- gcc/cp/cp-objcp-common.c    (revision 197239)
+++ gcc/cp/cp-objcp-common.c    (working copy)
@@ -62,7 +62,7 @@
     return false;
 
   /* Const variables take the place of #defines in C++.  */
-  if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl))
+  if (VAR_P (decl) && TREE_READONLY (decl))
     return false;
 
   return true;
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h    (revision 197239)
+++ gcc/cp/cp-tree.h    (working copy)
@@ -1918,9 +1918,8 @@
 
 /* True for DECL codes which have template info and access.  */
 #define LANG_DECL_HAS_MIN(NODE)                        \
-  (TREE_CODE (NODE) == FUNCTION_DECL           \
+  (VAR_OR_FUNCTION_DECL_P (NODE)               \
    || TREE_CODE (NODE) == FIELD_DECL           \
-   || TREE_CODE (NODE) == VAR_DECL             \
    || TREE_CODE (NODE) == CONST_DECL           \
    || TREE_CODE (NODE) == TYPE_DECL            \
    || TREE_CODE (NODE) == TEMPLATE_DECL                \
@@ -2200,8 +2199,7 @@
 
 /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
 #define DECL_DISCRIMINATOR_P(NODE)     \
-  (TREE_CODE (NODE) == VAR_DECL                \
-   && DECL_FUNCTION_SCOPE_P (NODE))
+  (VAR_P (NODE) && DECL_FUNCTION_SCOPE_P (NODE))
 
 /* Discriminator for name mangling.  */
 #define DECL_DISCRIMINATOR(NODE) (LANG_DECL_U2_CHECK (NODE, 1)->discriminator)
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c       (revision 197239)
+++ gcc/cp/decl.c       (working copy)
@@ -622,7 +622,7 @@
           push_local_binding where the list of decls returned by
           getdecls is built.  */
        decl = TREE_CODE (d) == TREE_LIST ? TREE_VALUE (d) : d;
-       if (TREE_CODE (decl) == VAR_DECL
+       if (VAR_P (decl)
            && (! TREE_USED (decl) || !DECL_READ_P (decl))
            && ! DECL_IN_SYSTEM_HEADER (decl)
            && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)
@@ -646,7 +646,7 @@
   /* Remove declarations for all the DECLs in this level.  */
   for (link = decls; link; link = TREE_CHAIN (link))
     {
-      if (leaving_for_scope && TREE_CODE (link) == VAR_DECL
+      if (leaving_for_scope && VAR_P (link)
          /* It's hard to make this ARM compatibility hack play nicely with
             lambdas, and it really isn't necessary in C++11 mode.  */
          && cxx_dialect < cxx0x
@@ -1084,7 +1084,7 @@
     {
       /* Need to check scope for variable declaration (VAR_DECL).
         For typedef (TYPE_DECL), scope is ignored.  */
-      if (TREE_CODE (newdecl) == VAR_DECL
+      if (VAR_P (newdecl)
          && CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl)
          /* [dcl.link]
             Two declarations for an object with C language linkage
@@ -1866,7 +1866,7 @@
          && newtype == DECL_ORIGINAL_TYPE (newdecl))
        newtype = oldtype;
 
-      if (TREE_CODE (newdecl) == VAR_DECL)
+      if (VAR_P (newdecl))
        {
          DECL_THIS_EXTERN (newdecl) |= DECL_THIS_EXTERN (olddecl);
          DECL_INITIALIZED_P (newdecl) |= DECL_INITIALIZED_P (olddecl);
@@ -1903,7 +1903,7 @@
          && !(processing_template_decl && uses_template_parms (newdecl)))
        layout_type (TREE_TYPE (newdecl));
 
-      if ((TREE_CODE (newdecl) == VAR_DECL
+      if ((VAR_P (newdecl)
           || TREE_CODE (newdecl) == PARM_DECL
           || TREE_CODE (newdecl) == RESULT_DECL
           || TREE_CODE (newdecl) == FIELD_DECL
@@ -1973,7 +1973,7 @@
          /* Keep the old RTL.  */
          COPY_DECL_RTL (olddecl, newdecl);
        }
-      else if (TREE_CODE (newdecl) == VAR_DECL
+      else if (VAR_P (newdecl)
               && (DECL_SIZE (olddecl) || !DECL_SIZE (newdecl)))
        {
          /* Keep the old RTL.  We cannot keep the old RTL if the old
@@ -2080,7 +2080,7 @@
            SET_DECL_THUNKS (newdecl, DECL_THUNKS (olddecl));
        }
       /* Only variables have this field.  */
-      else if (TREE_CODE (newdecl) == VAR_DECL
+      else if (VAR_P (newdecl)
               && VAR_HAD_UNKNOWN_BOUND (olddecl))
        SET_VAR_HAD_UNKNOWN_BOUND (newdecl);
     }
@@ -2256,7 +2256,7 @@
     }
   /* Init priority used to be merged from newdecl to olddecl by the memcpy,
      so keep this behavior.  */
-  if (TREE_CODE (newdecl) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P (newdecl))
+  if (VAR_P (newdecl) && DECL_HAS_INIT_PRIORITY_P (newdecl))
     {
       SET_DECL_INIT_PRIORITY (olddecl, DECL_INIT_PRIORITY (newdecl));
       DECL_HAS_INIT_PRIORITY_P (olddecl) = 1;
@@ -2285,7 +2285,7 @@
     TREE_USED (newdecl) = 1;
   else if (TREE_USED (newdecl))
     TREE_USED (olddecl) = 1;
-  if (TREE_CODE (newdecl) == VAR_DECL)
+  if (VAR_P (newdecl))
     {
       if (DECL_READ_P (olddecl))
        DECL_READ_P (newdecl) = 1;
@@ -2396,7 +2396,7 @@
     flags and attributes.  */
   if (DECL_RTL_SET_P (olddecl)
       && (TREE_CODE (olddecl) == FUNCTION_DECL
-         || (TREE_CODE (olddecl) == VAR_DECL
+         || (VAR_P (olddecl)
              && TREE_STATIC (olddecl))))
     make_decl_rtl (olddecl);
 
@@ -2539,7 +2539,7 @@
 
       return NULL;
     }
-  else if (TREE_CODE (newdecl) == VAR_DECL
+  else if (VAR_P (newdecl)
           && DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl)
           && (! DECL_LANG_SPECIFIC (olddecl)
               || ! CP_DECL_THREADPRIVATE_P (olddecl)
@@ -2564,8 +2564,8 @@
           union { int i; };
 
           is invalid.  */
-      if ((TREE_CODE (newdecl) == VAR_DECL && DECL_ANON_UNION_VAR_P (newdecl))
-         || (TREE_CODE (olddecl) == VAR_DECL && DECL_ANON_UNION_VAR_P 
(olddecl)))
+      if ((VAR_P (newdecl) && DECL_ANON_UNION_VAR_P (newdecl))
+         || (VAR_P (olddecl) && DECL_ANON_UNION_VAR_P (olddecl)))
        return G_("redeclaration of %q#D");
       /* If at least one declaration is a reference, there is no
         conflict.  For example:
@@ -2717,7 +2717,7 @@
      preceding types and is declared without an initializer (8.5).  */
   tree type = TREE_TYPE (decl);
 
-  if (TREE_CODE (decl) != VAR_DECL || TREE_STATIC (decl)
+  if (!VAR_P (decl) || TREE_STATIC (decl)
       || type == error_mark_node)
     return 0;
 
@@ -4529,10 +4529,10 @@
 
   if (TYPE_P (context) && COMPLETE_TYPE_P (complete_type (context)))
     {
-      if (TREE_CODE (decl) == VAR_DECL)
+      if (VAR_P (decl))
        {
          tree field = lookup_field (context, DECL_NAME (decl), 0, false);
-         if (field == NULL_TREE || TREE_CODE (field) != VAR_DECL)
+         if (field == NULL_TREE || !VAR_P (field))
            error ("%q#D is not a static member of %q#T", decl, context);
          else
            {
@@ -4609,7 +4609,7 @@
   if (decl == error_mark_node)
     return error_mark_node;
 
-  if (TREE_CODE (decl) == VAR_DECL
+  if (VAR_P (decl)
       && DECL_NAMESPACE_SCOPE_P (decl) && !TREE_PUBLIC (decl) && !was_public
       && !DECL_THIS_STATIC (decl) && !DECL_ARTIFICIAL (decl))
     {
@@ -4620,7 +4620,7 @@
       DECL_THIS_STATIC (decl) = 1;
     }
 
-  if (!processing_template_decl && TREE_CODE (decl) == VAR_DECL)
+  if (!processing_template_decl && VAR_P (decl))
     start_decl_1 (decl, initialized);
 
   return decl;
@@ -4645,7 +4645,7 @@
   if (error_operand_p (decl))
     return;
 
-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
+  gcc_assert (VAR_P (decl));
 
   type = TREE_TYPE (decl);
   complete_p = COMPLETE_TYPE_P (type);
@@ -4991,7 +4991,7 @@
   /* ``Unless explicitly declared extern, a const object does not have
      external linkage and must be initialized. ($8.4; $12.1)'' ARM
      7.1.6 */
-  if (TREE_CODE (decl) == VAR_DECL
+  if (VAR_P (decl)
       && TREE_CODE (type) != REFERENCE_TYPE
       && CP_TYPE_CONST_P (type)
       && !DECL_INITIAL (decl))
@@ -5778,7 +5778,7 @@
       /* The `register' keyword, when used together with an
         asm-specification, indicates that the variable should be
         placed in a particular register.  */
-      if (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
+      if (VAR_P (decl) && DECL_REGISTER (decl))
        {
          set_user_assembler_name (decl, asmspec);
          DECL_HARD_REGISTER (decl) = 1;
@@ -5793,7 +5793,7 @@
     }
 
   /* Handle non-variables up front.  */
-  if (TREE_CODE (decl) != VAR_DECL)
+  if (!VAR_P (decl))
     {
       rest_of_decl_compilation (decl, toplev, at_eof);
       return;
@@ -5911,7 +5911,7 @@
   tree cleanup;
   int already_used;
 
-  gcc_assert (TREE_CODE (decl) == VAR_DECL
+  gcc_assert (VAR_P (decl)
              || TREE_CODE (decl) == RESULT_DECL);
   gcc_assert (!TREE_STATIC (decl));
 
@@ -6147,7 +6147,7 @@
   if (!ensure_literal_type_for_constexpr_object (decl))
     DECL_DECLARED_CONSTEXPR_P (decl) = 0;
 
-  if (TREE_CODE (decl) == VAR_DECL
+  if (VAR_P (decl)
       && DECL_CLASS_SCOPE_P (decl)
       && DECL_INITIALIZED_IN_CLASS_P (decl))
     check_static_variable_definition (decl, type);
@@ -6178,7 +6178,7 @@
        }
     }
 
-  if (init && TREE_CODE (decl) == VAR_DECL)
+  if (init && VAR_P (decl))
     {
       DECL_NONTRIVIALLY_INITIALIZED_P (decl) = 1;
       /* If DECL is a reference, then we want to know whether init is a
@@ -6217,7 +6217,7 @@
         then it can be used in future constant expressions, so its value
         must be available. */
 
-      if (TREE_CODE (decl) != VAR_DECL || dependent_type_p (type))
+      if (!VAR_P (decl) || dependent_type_p (type))
        /* We can't do anything if the decl has dependent type.  */;
       else if (init
               && init_const_expr_p
@@ -6288,7 +6288,7 @@
       TREE_READONLY (decl) = 0;
     }
 
-  if (TREE_CODE (decl) == VAR_DECL)
+  if (VAR_P (decl))
     {
       /* If this is a local variable that will need a mangled name,
         register it now.  We must do this before processing the
@@ -6409,7 +6409,7 @@
      static data members in uninstantiated class templates.  */
   if (VAR_OR_FUNCTION_DECL_P (decl))
     {
-      if (TREE_CODE (decl) == VAR_DECL)
+      if (VAR_P (decl))
        {
          layout_var_decl (decl);
          maybe_commonize_var (decl);
@@ -6875,7 +6875,7 @@
 static void
 expand_static_init (tree decl, tree init)
 {
-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
+  gcc_assert (VAR_P (decl));
   gcc_assert (TREE_STATIC (decl));
 
   /* Some variables require no dynamic initialization.  */
@@ -10749,7 +10749,7 @@
       DECL_THIS_STATIC (decl) = 1;
 
     /* Set constexpr flag on vars (functions got it in grokfndecl).  */
-    if (constexpr_p && TREE_CODE (decl) == VAR_DECL)
+    if (constexpr_p && VAR_P (decl))
       DECL_DECLARED_CONSTEXPR_P (decl) = true;
 
     /* Record constancy and volatility on the DECL itself .  There's
@@ -10791,7 +10791,7 @@
 int
 local_variable_p (const_tree t)
 {
-  if ((TREE_CODE (t) == VAR_DECL
+  if ((VAR_P (t)
        /* A VAR_DECL with a context that is a _TYPE is a static data
          member.  */
        && !TYPE_P (CP_DECL_CONTEXT (t))
@@ -14036,7 +14036,7 @@
 void
 maybe_register_incomplete_var (tree var)
 {
-  gcc_assert (TREE_CODE (var) == VAR_DECL);
+  gcc_assert (VAR_P (var));
 
   /* Keep track of variables with incomplete types.  */
   if (!processing_template_decl && TREE_TYPE (var) != error_mark_node
@@ -14295,7 +14295,7 @@
   /* Virtual tables, construction virtual tables, and virtual table
      tables all go in a single COMDAT group, named after the primary
      virtual table.  */
-  if (TREE_CODE (decl) == VAR_DECL && DECL_VTABLE_OR_VTT_P (decl))
+  if (VAR_P (decl) && DECL_VTABLE_OR_VTT_P (decl))
     name = DECL_ASSEMBLER_NAME (CLASSTYPE_VTABLES (DECL_CONTEXT (decl)));
   /* For all other DECLs, the COMDAT group is the mangled name of the
      declaration itself.  */
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c      (revision 197239)
+++ gcc/cp/decl2.c      (working copy)
@@ -931,7 +931,7 @@
        }
       else if (TREE_CODE (value) == FIELD_DECL)
        /* C++11 NSDMI, keep going.  */;
-      else if (TREE_CODE (value) != VAR_DECL)
+      else if (!VAR_P (value))
        gcc_unreachable ();
       else if (!processing_template_decl)
        {
@@ -1603,7 +1603,7 @@
   if (flag_weak)
     make_decl_one_only (decl, cxx_comdat_group (decl));
   else if (TREE_CODE (decl) == FUNCTION_DECL
-          || (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)))
+          || (VAR_P (decl) && DECL_ARTIFICIAL (decl)))
     /* We can just emit function and compiler-generated variables
        statically; having multiple copies is (for the most part) only
        a waste of space.
@@ -1674,7 +1674,7 @@
     {
       make_decl_one_only (decl, cxx_comdat_group (decl));
 
-      if (TREE_CODE (decl) == VAR_DECL)
+      if (VAR_P (decl))
        {
          DECL_COMDAT (decl) = 1;
          /* Mark it needed so we don't forget to emit it.  */
@@ -2075,7 +2075,7 @@
 
       /* Virtual tables have DECL_CONTEXT set to their associated class,
         so they are automatically handled above.  */
-      gcc_assert (TREE_CODE (decl) != VAR_DECL
+      gcc_assert (!VAR_P (decl)
                  || !DECL_VTABLE_OR_VTT_P (decl));
 
       if (DECL_FUNCTION_SCOPE_P (decl) && ! DECL_VISIBILITY_SPECIFIED (decl))
@@ -2112,7 +2112,7 @@
             but have no TEMPLATE_INFO, so don't try to check it.  */
          use_template = 0;
        }
-      else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl)
+      else if (VAR_P (decl) && DECL_TINFO_P (decl)
               && flag_visibility_ms_compat)
        {
          /* Under -fvisibility-ms-compat, types are visible by default,
@@ -2126,7 +2126,7 @@
          else
            DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
        }
-      else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl))
+      else if (VAR_P (decl) && DECL_TINFO_P (decl))
        {
          /* tinfo visibility is based on the type it's for.  */
          constrain_visibility
@@ -2244,7 +2244,7 @@
      symbol flags are updated.  */
   if ((DECL_VISIBILITY (decl) != orig_visibility
        || DECL_VISIBILITY_SPECIFIED (decl) != orig_visibility_specified)
-      && ((TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
+      && ((VAR_P (decl) && TREE_STATIC (decl))
          || TREE_CODE (decl) == FUNCTION_DECL)
       && DECL_RTL_SET_P (decl))
     make_decl_rtl (decl);
@@ -2271,7 +2271,7 @@
 
   /* Give the target a chance to override the visibility associated
      with DECL.  */
-  if (TREE_CODE (decl) == VAR_DECL
+  if (VAR_P (decl)
       && (DECL_TINFO_P (decl)
          || (DECL_VTABLE_OR_VTT_P (decl)
              /* Construction virtual tables are not exported because
@@ -2447,7 +2447,7 @@
     {
       /* The repository indicates that this entity should be defined
         here.  Make sure the back end honors that request.  */
-      if (TREE_CODE (decl) == VAR_DECL)
+      if (VAR_P (decl))
        mark_needed (decl);
       else if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)
               || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl))
@@ -2468,7 +2468,7 @@
     /* We have already decided what to do with this DECL; there is no
        need to check anything further.  */
     ;
-  else if (TREE_CODE (decl) == VAR_DECL && DECL_VTABLE_OR_VTT_P (decl))
+  else if (VAR_P (decl) && DECL_VTABLE_OR_VTT_P (decl))
     {
       class_type = DECL_CONTEXT (decl);
       import_export_class (class_type);
@@ -2534,7 +2534,7 @@
       else
        comdat_p = true;
     }
-  else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl))
+  else if (VAR_P (decl) && DECL_TINFO_P (decl))
     {
       tree type = TREE_TYPE (DECL_NAME (decl));
       if (CLASS_TYPE_P (type))
@@ -3267,7 +3267,7 @@
       tree var;
 
       for (var = BIND_EXPR_VARS (*node); var; var = DECL_CHAIN (var))
-       if (TREE_CODE (var) == VAR_DECL
+       if (VAR_P (var)
          && !DECL_NAME (var)
          && DECL_ARTIFICIAL (var)
          && !DECL_CONTEXT (var))
@@ -3516,7 +3516,7 @@
        }
 
       /* The only things that can be initialized are variables.  */
-      gcc_assert (TREE_CODE (decl) == VAR_DECL);
+      gcc_assert (VAR_P (decl));
 
       /* If this object is not defined, we don't need to do anything
         here.  */
@@ -3796,7 +3796,7 @@
     return (DECL_INITIAL (decl) != NULL_TREE);
   else
     {
-      gcc_assert (TREE_CODE (decl) == VAR_DECL);
+      gcc_assert (VAR_P (decl));
       return !DECL_EXTERNAL (decl);
     }
 }
@@ -3838,7 +3838,7 @@
 decl_maybe_constant_var_p (tree decl)
 {
   tree type = TREE_TYPE (decl);
-  if (TREE_CODE (decl) != VAR_DECL)
+  if (!VAR_P (decl))
     return false;
   if (DECL_DECLARED_CONSTEXPR_P (decl))
     return true;
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c      (revision 197239)
+++ gcc/cp/error.c      (working copy)
@@ -916,7 +916,7 @@
 {
   if (flags & TFF_DECL_SPECIFIERS)
     {
-      if (TREE_CODE (t) == VAR_DECL
+      if (VAR_P (t)
          && DECL_DECLARED_CONSTEXPR_P (t))
        pp_cxx_ws_string (cxx_pp, "constexpr");
       dump_type_prefix (type, flags & ~TFF_UNQUALIFIED_NAME);
@@ -1249,7 +1249,7 @@
               ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
                | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
   else if (DECL_TEMPLATE_RESULT (t)
-           && (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL
+           && (VAR_P (DECL_TEMPLATE_RESULT (t))
               /* Alias template.  */
               || DECL_TYPE_TEMPLATE_P (t)))
     dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME);
@@ -3283,7 +3283,7 @@
     case 'D':
       {
        tree temp = next_tree;
-       if (TREE_CODE (temp) == VAR_DECL
+       if (VAR_P (temp)
            && DECL_HAS_DEBUG_EXPR_P (temp))
          {
            temp = DECL_DEBUG_EXPR (temp);
Index: gcc/cp/except.c
===================================================================
--- gcc/cp/except.c     (revision 197239)
+++ gcc/cp/except.c     (working copy)
@@ -828,7 +828,7 @@
             treated as an rvalue for the purposes of overload resolution
             to favor move constructors over copy constructors.  */
          if (/* Must be a local, automatic variable.  */
-             TREE_CODE (exp) == VAR_DECL
+             VAR_P (exp)
              && DECL_CONTEXT (exp) == current_function_decl
              && ! TREE_STATIC (exp)
              /* The variable must not have the `volatile' qualifier.  */
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c       (revision 197239)
+++ gcc/cp/init.c       (working copy)
@@ -1131,7 +1131,7 @@
 
   /* Now compute the address to use when initializing the vptr.  */
   vtbl = unshare_expr (BINFO_VTABLE (binfo_for));
-  if (TREE_CODE (vtbl) == VAR_DECL)
+  if (VAR_P (vtbl))
     vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl);
 
   return vtbl;
@@ -1293,7 +1293,7 @@
             member_name);
       return 0;
     }
-  if (TREE_CODE (field) == VAR_DECL)
+  if (VAR_P (field))
     {
       error ("%q#D is a static data member; it can only be "
             "initialized at its definition",
@@ -1515,7 +1515,7 @@
       return stmt_expr;
     }
 
-  if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL)
+  if (VAR_P (exp) || TREE_CODE (exp) == PARM_DECL)
     /* Just know that we've seen something for this node.  */
     TREE_USED (exp) = 1;
 
@@ -1728,7 +1728,7 @@
      in and expand the constructor.  Constructors now come
      as TARGET_EXPRs.  */
 
-  if (init && TREE_CODE (exp) == VAR_DECL
+  if (init && VAR_P (exp)
       && COMPOUND_LITERAL_P (init))
     {
       vec<tree, va_gc> *cleanups = NULL;
@@ -1849,7 +1849,7 @@
      processing.  */
   if (TREE_CODE (member) == TYPE_DECL)
     return member;
-  if (TREE_CODE (member) == VAR_DECL || TREE_CODE (member) == CONST_DECL)
+  if (VAR_P (member) || TREE_CODE (member) == CONST_DECL)
     return convert_from_reference (member);
 
   if (TREE_CODE (member) == FIELD_DECL && DECL_C_BIT_FIELD (member))
@@ -1964,7 +1964,7 @@
   while (TREE_CODE (decl) == CONST_DECL
         || (integral_p
             ? decl_constant_var_p (decl)
-            : (TREE_CODE (decl) == VAR_DECL
+            : (VAR_P (decl)
                && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl)))))
     {
       tree init;
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c     (revision 197239)
+++ gcc/cp/mangle.c     (working copy)
@@ -663,7 +663,7 @@
          write_source_name (DECL_NAME (decl));
        }
     }
-  else if (TREE_CODE (decl) == VAR_DECL
+  else if (VAR_P (decl)
           /* The names of non-static global variables aren't mangled.  */
           && DECL_EXTERNAL_LINKAGE_P (decl)
           && (CP_DECL_CONTEXT (decl) == global_namespace
@@ -1042,7 +1042,7 @@
     {
       write_prefix (decl_mangling_context (decl));
       write_unqualified_name (decl);
-      if (TREE_CODE (decl) == VAR_DECL
+      if (VAR_P (decl)
          || TREE_CODE (decl) == FIELD_DECL)
        {
          /* <data-member-prefix> := <member source-name> M */
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c        (revision 197239)
+++ gcc/cp/name-lookup.c        (working copy)
@@ -509,8 +509,8 @@
 
        A member shall not be declared twice in the
        member-specification.  */
-  else if (TREE_CODE (target_decl) == VAR_DECL
-          && TREE_CODE (target_bval) == VAR_DECL
+  else if (VAR_P (target_decl)
+          && VAR_P (target_bval)
           && DECL_EXTERNAL (target_decl) && DECL_EXTERNAL (target_bval)
           && !DECL_CLASS_SCOPE_P (target_decl))
     {
@@ -574,7 +574,7 @@
 {
   /* We used to record virtual tables as if they were ordinary
      variables, but no longer do so.  */
-  gcc_assert (!(TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl)));
+  gcc_assert (!(VAR_P (decl) && DECL_VIRTUAL_P (decl)));
 
   if (TREE_CODE (decl) == NAMESPACE_DECL
       && !DECL_NAMESPACE_ALIAS (decl))
@@ -594,7 +594,7 @@
         static later.  It's OK for this list to contain a few false
         positives.  */
       if (b->kind == sk_namespace)
-       if ((TREE_CODE (decl) == VAR_DECL
+       if ((VAR_P (decl)
             && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
            || (TREE_CODE (decl) == FUNCTION_DECL
                && (!TREE_PUBLIC (decl) || DECL_DECLARED_INLINE_P (decl))))
@@ -636,7 +636,7 @@
          /* A local declaration for an `extern' variable is in the
             scope of the current namespace, not the current
             function.  */
-         && !(TREE_CODE (x) == VAR_DECL && DECL_EXTERNAL (x))
+         && !(VAR_P (x) && DECL_EXTERNAL (x))
          /* When parsing the parameter list of a function declarator,
             don't set DECL_CONTEXT to an enclosing function.  When we
             push the PARM_DECLs in order to process the function body,
@@ -973,7 +973,7 @@
          if (!(TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x)
                && t != NULL_TREE)
              && (TREE_CODE (x) == TYPE_DECL
-                 || TREE_CODE (x) == VAR_DECL
+                 || VAR_P (x)
                  || TREE_CODE (x) == NAMESPACE_DECL
                  || TREE_CODE (x) == CONST_DECL
                  || TREE_CODE (x) == TEMPLATE_DECL))
@@ -1021,7 +1021,7 @@
              tree d = oldlocal;
 
              while (oldlocal
-                    && TREE_CODE (oldlocal) == VAR_DECL
+                    && VAR_P (oldlocal)
                     && DECL_DEAD_FOR_LOCAL (oldlocal))
                oldlocal = DECL_SHADOWED_FOR_VAR (oldlocal);
 
@@ -1065,7 +1065,7 @@
                   /* Inline decls shadow nothing.  */
                   && !DECL_FROM_INLINE (x)
                   && (TREE_CODE (oldlocal) == PARM_DECL
-                      || TREE_CODE (oldlocal) == VAR_DECL
+                      || VAR_P (oldlocal)
                        /* If the old decl is a type decl, only warn if the
                           old decl is an explicit typedef or if both the old
                           and new decls are type decls.  */
@@ -1125,7 +1125,7 @@
                 outermost block of the controlled statement.
                 Redeclaring a variable from a for or while condition is
                 detected elsewhere.  */
-             else if (TREE_CODE (oldlocal) == VAR_DECL
+             else if (VAR_P (oldlocal)
                       && oldscope == current_binding_level->level_chain
                       && (oldscope->kind == sk_cond
                           || oldscope->kind == sk_for))
@@ -1179,7 +1179,7 @@
                           x);
                }
              else if (oldglobal != NULL_TREE
-                      && (TREE_CODE (oldglobal) == VAR_DECL
+                      && (VAR_P (oldglobal)
                            /* If the old decl is a type decl, only warn if the
                               old decl is an explicit typedef or if both the
                               old and new decls are type decls.  */
@@ -1196,7 +1196,7 @@
            }
        }
 
-      if (TREE_CODE (x) == VAR_DECL)
+      if (VAR_P (x))
        maybe_register_incomplete_var (x);
     }
 
@@ -1309,12 +1309,12 @@
   tree shadowed;
 
   /* We only care about out of scope variables.  */
-  if (!(TREE_CODE (decl) == VAR_DECL && DECL_DEAD_FOR_LOCAL (decl)))
+  if (!(VAR_P (decl) && DECL_DEAD_FOR_LOCAL (decl)))
     return decl;
 
   shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (decl)
     ? DECL_SHADOWED_FOR_VAR (decl) : NULL_TREE ;
-  while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
+  while (shadowed != NULL_TREE && VAR_P (shadowed)
         && DECL_DEAD_FOR_LOCAL (shadowed))
     shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (shadowed)
       ? DECL_SHADOWED_FOR_VAR (shadowed) : NULL_TREE;
@@ -2435,7 +2435,7 @@
 
   if (using_decl == NULL_TREE
       && at_function_scope_p ()
-      && TREE_CODE (decl) == VAR_DECL)
+      && VAR_P (decl))
     /* C++11 7.3.3/10.  */
     error ("%qD is already declared in this scope", name);
   
@@ -3061,7 +3061,7 @@
 
      (Non-static data members were also forbidden to have the same
      name as T until TC1.)  */
-  if ((TREE_CODE (x) == VAR_DECL
+  if ((VAR_P (x)
        || TREE_CODE (x) == CONST_DECL
        || (TREE_CODE (x) == TYPE_DECL
           && !DECL_SELF_REFERENCE_P (x))
@@ -4955,7 +4955,7 @@
       while (1)
        {
          if (binding->scope == b
-             && !(TREE_CODE (binding->value) == VAR_DECL
+             && !(VAR_P (binding->value)
                   && DECL_DEAD_FOR_LOCAL (binding->value)))
            return binding->value;
 
@@ -4994,7 +4994,7 @@
   if (TREE_CODE (decl) == FUNCTION_DECL)
     return DECL_LOCAL_FUNCTION_P (decl);
 
-  if (TREE_CODE (decl) != VAR_DECL)
+  if (!VAR_P (decl))
     return false;
   if (!current_function_decl)
     return false;
@@ -5554,7 +5554,7 @@
   fns = k.functions;
   
   if (fns
-      && TREE_CODE (fns) != VAR_DECL
+      && !VAR_P (fns)
       && !is_overloaded_fn (fns))
     {
       error ("argument dependent lookup finds %q+D", fns);
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c     (revision 197239)
+++ gcc/cp/parser.c     (working copy)
@@ -8479,7 +8479,7 @@
              continue;
            }
          else if (DECL_P (capture_init_expr)
-                  && (TREE_CODE (capture_init_expr) != VAR_DECL
+                  && (!VAR_P (capture_init_expr)
                       && TREE_CODE (capture_init_expr) != PARM_DECL))
            {
              error_at (capture_token->location,
@@ -8488,7 +8488,7 @@
              inform (0, "%q+#D declared here", capture_init_expr);
              continue;
            }
-         if (TREE_CODE (capture_init_expr) == VAR_DECL
+         if (VAR_P (capture_init_expr)
              && decl_storage_duration (capture_init_expr) != dk_auto)
            {
              pedwarn (capture_token->location, 0, "capture of variable "
@@ -13332,7 +13332,7 @@
          probe = argument;
          if (TREE_CODE (probe) == SCOPE_REF)
            probe = TREE_OPERAND (probe, 1);
-         if (TREE_CODE (probe) == VAR_DECL)
+         if (VAR_P (probe))
            {
              /* A variable without external linkage might still be a
                 valid constant-expression, so no error is issued here
@@ -22146,7 +22146,7 @@
         decl = error_mark_node;
       }
 
-    if (decl && TREE_CODE (decl) == VAR_DECL)
+    if (decl && VAR_P (decl))
       check_template_variable (decl);
     }
 
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 197239)
+++ gcc/cp/pt.c (working copy)
@@ -5646,7 +5646,7 @@
       else if (TREE_CODE (expr) != ADDR_EXPR
               && TREE_CODE (expr_type) != ARRAY_TYPE)
        {
-         if (TREE_CODE (expr) == VAR_DECL)
+         if (VAR_P (expr))
            {
              error ("%qD is not a valid template argument "
                     "because %qD is a variable, not the address of "
@@ -5671,7 +5671,7 @@
 
          decl = ((TREE_CODE (expr) == ADDR_EXPR)
                  ? TREE_OPERAND (expr, 0) : expr);
-         if (TREE_CODE (decl) != VAR_DECL)
+         if (!VAR_P (decl))
            {
              error ("%qE is not a valid template argument of type %qT "
                     "because %qE is not a variable",
@@ -8837,7 +8837,7 @@
                  r = tsubst (t, args, tf_warning_or_error, NULL_TREE);
                  if (TREE_CODE (t) == TEMPLATE_DECL)
                    --processing_template_decl;
-                 if (TREE_CODE (r) == VAR_DECL)
+                 if (VAR_P (r))
                    {
                      /* In [temp.inst]:
 
@@ -10639,7 +10639,7 @@
            break;
          }
 
-       if (TREE_CODE (t) == VAR_DECL && DECL_ANON_UNION_VAR_P (t))
+       if (VAR_P (t) && DECL_ANON_UNION_VAR_P (t))
          {
            /* Just use name lookup to find a member alias for an anonymous
               union, but then add it to the hash table.  */
@@ -10657,13 +10657,13 @@
              type = DECL_ORIGINAL_TYPE (t);
            else
              type = TREE_TYPE (t);
-           if (TREE_CODE (t) == VAR_DECL
+           if (VAR_P (t)
                && VAR_HAD_UNKNOWN_BOUND (t)
                && type != error_mark_node)
              type = strip_array_domain (type);
            type = tsubst (type, args, complain, in_decl);
          }
-       if (TREE_CODE (r) == VAR_DECL)
+       if (VAR_P (r))
          {
            /* Even if the original location is out of scope, the
               newly substituted one is not.  */
@@ -10727,7 +10727,7 @@
        if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL))
          SET_DECL_RTL (r, NULL);
        DECL_SIZE (r) = DECL_SIZE_UNIT (r) = 0;
-       if (TREE_CODE (r) == VAR_DECL)
+       if (VAR_P (r))
          {
            /* Possibly limit visibility based on template args.  */
            DECL_VISIBILITY (r) = VISIBILITY_DEFAULT;
@@ -12897,9 +12897,9 @@
                   handle local variables, and since we've already done
                   all that needs to be done, that's the right thing to
                   do.  */
-               if (TREE_CODE (decl) == VAR_DECL)
+               if (VAR_P (decl))
                  DECL_TEMPLATE_INSTANTIATED (decl) = 1;
-               if (TREE_CODE (decl) == VAR_DECL
+               if (VAR_P (decl)
                    && ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
                  /* Anonymous aggregates are a special case.  */
                  finish_anon_union (decl);
@@ -12920,7 +12920,7 @@
                  {
                    int const_init = false;
                    maybe_push_decl (decl);
-                   if (TREE_CODE (decl) == VAR_DECL
+                   if (VAR_P (decl)
                        && DECL_PRETTY_FUNCTION_P (decl))
                      {
                        /* For __PRETTY_FUNCTION__ we have to adjust the
@@ -12951,7 +12951,7 @@
                          init = t;
                      }
 
-                   if (TREE_CODE (decl) == VAR_DECL)
+                   if (VAR_P (decl))
                      const_init = (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P
                                    (pattern_decl));
                    cp_finish_decl (decl, init, const_init, NULL_TREE, 0);
@@ -18008,7 +18008,7 @@
       error ("explicit instantiation of non-template %q#D", decl);
       return;
     }
-  else if (TREE_CODE (decl) == VAR_DECL)
+  else if (VAR_P (decl))
     {
       /* There is an asymmetry here in the way VAR_DECLs and
         FUNCTION_DECLs are handled by grokdeclarator.  In the case of
@@ -18024,7 +18024,7 @@
          return;
        }
       result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false);
-      if (!result || TREE_CODE (result) != VAR_DECL)
+      if (!result || !VAR_P (result))
        {
          error ("no matching template for %qD found", decl);
          return;
@@ -18286,7 +18286,7 @@
          instantiate_class_member (tmp, extern_p);
 
     for (tmp = TYPE_FIELDS (t); tmp; tmp = DECL_CHAIN (tmp))
-      if (TREE_CODE (tmp) == VAR_DECL && DECL_TEMPLATE_INSTANTIATION (tmp))
+      if (VAR_P (tmp) && DECL_TEMPLATE_INSTANTIATION (tmp))
        instantiate_class_member (tmp, extern_p);
 
     if (CLASSTYPE_NESTED_UTDS (t))
@@ -18415,7 +18415,7 @@
          && !DECL_DECLARED_INLINE_P (decl))
        DECL_DECLARED_INLINE_P (decl) = 1;
     }
-  else if (TREE_CODE (decl) == VAR_DECL)
+  else if (VAR_P (decl))
     {
       DECL_INITIAL (decl) =
        tsubst_expr (DECL_INITIAL (code_pattern), args,
@@ -18479,7 +18479,7 @@
         cannot restructure the loop to just keep going until we find
         a template with a definition, since that might go too far if
         a specialization was declared, but not defined.  */
-      gcc_assert (TREE_CODE (decl) != VAR_DECL
+      gcc_assert (!VAR_P (decl)
                  || DECL_IN_AGGR_P (DECL_TEMPLATE_RESULT (tmpl)));
 
       /* Fetch the more general template.  */
@@ -18507,7 +18507,7 @@
          /* And we need to instantiate static data members so that
             their initializers are available in integral constant
             expressions.  */
-         || (TREE_CODE (decl) == VAR_DECL
+         || (VAR_P (decl)
              && decl_maybe_constant_var_p (decl)));
 }
 
@@ -18611,7 +18611,7 @@
      case that an expression refers to the value of the variable --
      if the variable has a constant value the referring expression can
      take advantage of that fact.  */
-  if (TREE_CODE (d) == VAR_DECL
+  if (VAR_P (d)
       || DECL_DECLARED_CONSTEXPR_P (d))
     defer_ok = 0;
 
@@ -18730,11 +18730,11 @@
         elsewhere, we don't want to instantiate the entire data
         member, but we do want to instantiate the initializer so that
         we can substitute that elsewhere.  */
-      || (external_p && TREE_CODE (d) == VAR_DECL))
+      || (external_p && VAR_P (d)))
     {
       /* The definition of the static data member is now required so
         we must substitute the initializer.  */
-      if (TREE_CODE (d) == VAR_DECL
+      if (VAR_P (d)
          && !DECL_INITIAL (d)
          && DECL_INITIAL (code_pattern))
        {
@@ -18784,7 +18784,7 @@
        goto out;
       /* ??? Historically, we have instantiated inline functions, even
         when marked as "extern template".  */
-      if (!(external_p && TREE_CODE (d) == VAR_DECL))
+      if (!(external_p && VAR_P (d)))
        add_pending_template (d);
       goto out;
     }
@@ -18824,7 +18824,7 @@
      they changed as a result of calling regenerate_decl_from_template.  */
   input_location = DECL_SOURCE_LOCATION (d);
 
-  if (TREE_CODE (d) == VAR_DECL)
+  if (VAR_P (d))
     {
       tree init;
       bool const_init = false;
@@ -19873,7 +19873,7 @@
   /* A static data member of the current instantiation with incomplete
      array type is type-dependent, as the definition and specializations
      can have different bounds.  */
-  if (TREE_CODE (expression) == VAR_DECL
+  if (VAR_P (expression)
       && DECL_CLASS_SCOPE_P (expression)
       && dependent_type_p (DECL_CONTEXT (expression))
       && VAR_HAD_UNKNOWN_BOUND (expression))
@@ -20467,7 +20467,7 @@
       || TREE_CODE (inner_expr) == OFFSET_REF)
     return expr;
   /* There is no need to return a proxy for a variable.  */
-  if (TREE_CODE (expr) == VAR_DECL)
+  if (VAR_P (expr))
     return expr;
   /* Preserve string constants; conversions from string constants to
      "char *" are allowed, even though normally a "const char *"
Index: gcc/cp/repo.c
===================================================================
--- gcc/cp/repo.c       (revision 197239)
+++ gcc/cp/repo.c       (working copy)
@@ -302,7 +302,7 @@
      is an artificial restriction; the code in the prelinker and here
      will work fine if all entities with vague linkage are managed by
      the repository.  */
-  if (TREE_CODE (decl) == VAR_DECL)
+  if (VAR_P (decl))
     {
       tree type = NULL_TREE;
       if (DECL_VTABLE_OR_VTT_P (decl))
Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c       (revision 197239)
+++ gcc/cp/rtti.c       (working copy)
@@ -635,7 +635,7 @@
        {
          /* if b is an object, dynamic_cast<void *>(&b) == (void *)&b.  */
          if (TREE_CODE (expr) == ADDR_EXPR
-             && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
+             && VAR_P (TREE_OPERAND (expr, 0))
              && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE)
            return build1 (NOP_EXPR, type, expr);
 
@@ -658,7 +658,7 @@
             dynamic_cast<D&>(b) (b an object) cannot succeed.  */
          if (tc == REFERENCE_TYPE)
            {
-             if (TREE_CODE (old_expr) == VAR_DECL
+             if (VAR_P (old_expr)
                  && TREE_CODE (TREE_TYPE (old_expr)) == RECORD_TYPE)
                {
                  tree expr = throw_bad_cast ();
@@ -674,7 +674,7 @@
          else if (TREE_CODE (expr) == ADDR_EXPR)
            {
              tree op = TREE_OPERAND (expr, 0);
-             if (TREE_CODE (op) == VAR_DECL
+             if (VAR_P (op)
                  && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
                {
                   if (complain & tf_warning)
Index: gcc/cp/search.c
===================================================================
--- gcc/cp/search.c     (revision 197239)
+++ gcc/cp/search.c     (working copy)
@@ -983,7 +983,7 @@
 int
 shared_member_p (tree t)
 {
-  if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == TYPE_DECL \
+  if (VAR_P (t) || TREE_CODE (t) == TYPE_DECL \
       || TREE_CODE (t) == CONST_DECL)
     return 1;
   if (is_overloaded_fn (t))
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c  (revision 197239)
+++ gcc/cp/semantics.c  (working copy)
@@ -2887,7 +2887,7 @@
 static bool
 outer_var_p (tree decl)
 {
-  return ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
+  return ((VAR_P (decl) || TREE_CODE (decl) == PARM_DECL)
          && DECL_FUNCTION_SCOPE_P (decl)
          && (DECL_CONTEXT (decl) != current_function_decl
              || parsing_nsdmi ()));
@@ -3083,7 +3083,7 @@
            }
          else
            {
-             error (TREE_CODE (decl) == VAR_DECL
+             error (VAR_P (decl)
                     ? G_("use of local variable with automatic storage from 
containing function")
                     : G_("use of parameter from containing function"));
              error ("  %q+#D declared here", decl);
@@ -3259,7 +3259,7 @@
          /* If we found a variable, then name lookup during the
             instantiation will always resolve to the same VAR_DECL
             (or an instantiation thereof).  */
-         if (TREE_CODE (decl) == VAR_DECL
+         if (VAR_P (decl)
              || TREE_CODE (decl) == PARM_DECL)
            {
              mark_used (decl);
@@ -3303,7 +3303,7 @@
 
       /* Mark variable-like entities as used.  Functions are similarly
         marked either below or after overload resolution.  */
-      if ((TREE_CODE (decl) == VAR_DECL
+      if ((VAR_P (decl)
           || TREE_CODE (decl) == PARM_DECL
           || TREE_CODE (decl) == CONST_DECL
           || TREE_CODE (decl) == RESULT_DECL)
@@ -3328,7 +3328,7 @@
        }
 
       tree wrap;
-      if (TREE_CODE (decl) == VAR_DECL
+      if (VAR_P (decl)
          && !cp_unevaluated_operand
          && DECL_THREAD_LOCAL_P (decl)
          && (wrap = get_tls_wrapper_fn (decl)))
@@ -4061,7 +4061,7 @@
          goto check_dup_generic;
        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)
            {
              if (processing_template_decl)
                break;
@@ -4084,7 +4084,7 @@
 
        case OMP_CLAUSE_FIRSTPRIVATE:
          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;
@@ -4106,7 +4106,7 @@
 
        case OMP_CLAUSE_LASTPRIVATE:
          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;
@@ -4258,7 +4258,7 @@
 
       t = OMP_CLAUSE_DECL (c);
       if (processing_template_decl
-         && TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+         && !VAR_P (t) && TREE_CODE (t) != PARM_DECL)
        {
          pc = &OMP_CLAUSE_CHAIN (c);
          continue;
@@ -4298,7 +4298,7 @@
          break;
 
        case OMP_CLAUSE_COPYIN:
-         if (TREE_CODE (t) != VAR_DECL || !DECL_THREAD_LOCAL_P (t))
+         if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
            {
              error ("%qE must be %<threadprivate%> for %<copyin%>", t);
              remove = true;
@@ -4325,7 +4325,7 @@
        {
          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 (cxx_omp_predetermined_sharing (t))
            {
@@ -4392,7 +4392,7 @@
 
       if (error_operand_p (v))
        ;
-      else if (TREE_CODE (v) != VAR_DECL)
+      else if (!VAR_P (v))
        error ("%<threadprivate%> %qD is not file, namespace "
               "or block scope variable", v);
       /* If V had already been marked threadprivate, it doesn't matter
@@ -5295,7 +5295,7 @@
 
   /* To get the size of a static data member declared as an array of
      unknown bound, we need to instantiate it.  */
-  if (TREE_CODE (expr) == VAR_DECL
+  if (VAR_P (expr)
       && VAR_HAD_UNKNOWN_BOUND (expr)
       && DECL_TEMPLATE_INSTANTIATION (expr))
     instantiate_decl (expr, /*defer_ok*/true, /*expl_inst_mem*/false);
@@ -5727,7 +5727,7 @@
 ensure_literal_type_for_constexpr_object (tree decl)
 {
   tree type = TREE_TYPE (decl);
-  if (TREE_CODE (decl) == VAR_DECL && DECL_DECLARED_CONSTEXPR_P (decl)
+  if (VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl)
       && !processing_template_decl)
     {
       if (CLASS_TYPE_P (type) && !COMPLETE_TYPE_P (complete_type (type)))
@@ -9200,7 +9200,7 @@
 bool
 is_capture_proxy (tree decl)
 {
-  return (TREE_CODE (decl) == VAR_DECL
+  return (VAR_P (decl)
          && DECL_HAS_VALUE_EXPR_P (decl)
          && !DECL_ANON_UNION_VAR_P (decl)
          && LAMBDA_FUNCTION_P (DECL_CONTEXT (decl)));
Index: gcc/cp/tree.c
===================================================================
--- gcc/cp/tree.c       (revision 197239)
+++ gcc/cp/tree.c       (working copy)
@@ -70,7 +70,7 @@
       /* unnamed rvalue references are rvalues */
       if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
          && TREE_CODE (ref) != PARM_DECL
-         && TREE_CODE (ref) != VAR_DECL
+         && !VAR_P (ref)
          && TREE_CODE (ref) != COMPONENT_REF
          /* Functions are always lvalues.  */
          && TREE_CODE (TREE_TYPE (TREE_TYPE (ref))) != FUNCTION_TYPE)
@@ -2219,7 +2219,7 @@
 {
   splay_tree target_remap = ((splay_tree) data);
 
-  if (TREE_CODE (*t) == VAR_DECL)
+  if (VAR_P (*t))
     {
       splay_tree_node n = splay_tree_lookup (target_remap,
                                             (splay_tree_key) *t);
@@ -2584,10 +2584,10 @@
           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 (!cp_tree_equal (o1, o2))
@@ -3149,7 +3149,7 @@
   type = strip_array_types (type);
 
   if (decl == NULL_TREE
-      || TREE_CODE (decl) != VAR_DECL
+      || !VAR_P (decl)
       || !TREE_STATIC (decl)
       || DECL_EXTERNAL (decl)
       || (TREE_CODE (type) != RECORD_TYPE
@@ -3618,7 +3618,7 @@
     return dk_auto;
   if (TREE_CODE (decl) == FUNCTION_DECL)
     return dk_static;
-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
+  gcc_assert (VAR_P (decl));
   if (!TREE_STATIC (decl)
       && !DECL_EXTERNAL (decl))
     return dk_auto;
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c     (revision 197239)
+++ gcc/cp/typeck.c     (working copy)
@@ -1581,7 +1581,7 @@
 
   /* To get the size of a static data member declared as an array of
      unknown bound, we need to instantiate it.  */
-  if (TREE_CODE (e) == VAR_DECL
+  if (VAR_P (e)
       && VAR_HAD_UNKNOWN_BOUND (e)
       && DECL_TEMPLATE_INSTANTIATION (e))
     instantiate_decl (e, /*defer_ok*/true, /*expl_inst_mem*/false);
@@ -1645,7 +1645,7 @@
 
   e = mark_type_use (e);
 
-  if (TREE_CODE (e) == VAR_DECL)
+  if (VAR_P (e))
     t = size_int (DECL_ALIGN_UNIT (e));
   else if (TREE_CODE (e) == COMPONENT_REF
           && TREE_CODE (TREE_OPERAND (e, 1)) == FIELD_DECL
@@ -1950,7 +1950,7 @@
 
       ptrtype = build_pointer_type (TREE_TYPE (type));
 
-      if (TREE_CODE (exp) == VAR_DECL)
+      if (VAR_P (exp))
        {
          if (!cxx_mark_addressable (exp))
            return error_mark_node;
@@ -2280,7 +2280,7 @@
 
   /* In [expr.ref], there is an explicit list of the valid choices for
      MEMBER.  We check for each of those cases here.  */
-  if (TREE_CODE (member) == VAR_DECL)
+  if (VAR_P (member))
     {
       /* A static data member.  */
       result = member;
@@ -3054,7 +3054,7 @@
          tree foo = array;
          while (TREE_CODE (foo) == COMPONENT_REF)
            foo = TREE_OPERAND (foo, 0);
-         if (TREE_CODE (foo) == VAR_DECL && DECL_REGISTER (foo)
+         if (VAR_P (foo) && DECL_REGISTER (foo)
              && (complain & tf_warning))
            warning_at (loc, OPT_Wextra,
                        "subscripting array declared %<register%>");
@@ -5772,7 +5772,7 @@
        if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
            && !DECL_ARTIFICIAL (x))
          {
-           if (TREE_CODE (x) == VAR_DECL && DECL_HARD_REGISTER (x))
+           if (VAR_P (x) && DECL_HARD_REGISTER (x))
              {
                error
                  ("address of explicit register variable %qD requested", x);
@@ -8050,7 +8050,7 @@
          warning (OPT_Wreturn_local_addr, "returning reference to temporary");
          return;
        }
-      if (TREE_CODE (whats_returned) == VAR_DECL
+      if (VAR_P (whats_returned)
          && DECL_NAME (whats_returned)
          && TEMP_NAME_P (DECL_NAME (whats_returned)))
        {
@@ -8288,7 +8288,7 @@
   named_return_value_okay_p = 
     (retval != NULL_TREE
      /* Must be a local, automatic variable.  */
-     && TREE_CODE (retval) == VAR_DECL
+     && VAR_P (retval)
      && DECL_CONTEXT (retval) == current_function_decl
      && ! TREE_STATIC (retval)
      && ! DECL_ANON_UNION_VAR_P (retval)
@@ -8336,7 +8336,7 @@
          Note that these conditions are similar to, but not as strict as,
         the conditions for the named return value optimization.  */
       if ((cxx_dialect != cxx98)
-          && (TREE_CODE (retval) == VAR_DECL
+          && (VAR_P (retval)
              || TREE_CODE (retval) == PARM_DECL)
          && DECL_CONTEXT (retval) == current_function_decl
          && !TREE_STATIC (retval)
Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c    (revision 197239)
+++ gcc/cp/typeck2.c    (working copy)
@@ -98,7 +98,7 @@
 
   /* Handle C++-specific things first.  */
 
-  if (TREE_CODE (arg) == VAR_DECL
+  if (VAR_P (arg)
       && DECL_LANG_SPECIFIC (arg)
       && DECL_IN_AGGR_P (arg)
       && !TREE_STATIC (arg))
@@ -113,7 +113,7 @@
                          arg);
   else if (INDIRECT_REF_P (arg)
           && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
-          && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
+          && (VAR_P (TREE_OPERAND (arg, 0))
               || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
     ERROR_FOR_ASSIGNMENT (G_("assignment of "
                              "read-only reference %qD"),
@@ -315,7 +315,7 @@
 
   if (decl)
     {
-      if (TREE_CODE (decl) == VAR_DECL)
+      if (VAR_P (decl))
        error ("cannot declare variable %q+D to be of abstract "
               "type %qT", decl, type);
       else if (TREE_CODE (decl) == PARM_DECL)
@@ -441,7 +441,7 @@
   if (TREE_CODE (type) == ERROR_MARK)
     return;
 
-  if (value != 0 && (TREE_CODE (value) == VAR_DECL
+  if (value != 0 && (VAR_P (value)
                     || TREE_CODE (value) == PARM_DECL
                     || TREE_CODE (value) == FIELD_DECL))
     {
Index: gcc/tree.h
===================================================================
--- gcc/tree.h  (revision 197239)
+++ gcc/tree.h  (working copy)
@@ -165,6 +165,10 @@
 #define DECL_P(CODE)\
         (TREE_CODE_CLASS (TREE_CODE (CODE)) == tcc_declaration)
 
+/* True if NODE designates a variable declaration.  */
+#define VAR_P(NODE) \
+  (TREE_CODE (NODE) == VAR_DECL)
+
 /* Nonzero if DECL represents a VAR_DECL or FUNCTION_DECL.  */
 
 #define VAR_OR_FUNCTION_DECL_P(DECL)\

Reply via email to