[04/14] c++: use _P() defines from tree.h

Message ID 20230513232321.279733-5-rep.dot.nop@gmail.com
State Accepted
Headers
Series use _P() defines from tree.h |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Bernhard Reutner-Fischer May 13, 2023, 11:23 p.m. UTC
  From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/cp/ChangeLog:

	* call.cc (promoted_arithmetic_type_p): Use _P defines from tree.h.
	(build_conditional_expr): Ditto.
	(convert_like_internal): Ditto.
	(convert_arg_to_ellipsis): Ditto.
	(build_over_call): Ditto.
	(compare_ics): Ditto.
	* class.cc (is_empty_base_ref): Ditto.
	* coroutines.cc (rewrite_param_uses): Ditto.
	* cp-tree.h (DECL_DISCRIMINATOR_P): Ditto.
	(ARITHMETIC_TYPE_P): Ditto.
	* cvt.cc (ocp_convert): Ditto.
	* cxx-pretty-print.cc (pp_cxx_template_argument_list): Ditto.
	* decl.cc (layout_var_decl): Ditto.
	(get_tuple_size): Ditto.
	* error.cc (dump_simple_decl): Ditto.
	* lambda.cc (start_lambda_scope): Ditto.
	* mangle.cc (write_template_arg): Ditto.
	* method.cc (spaceship_comp_cat): Ditto.
	* module.cc (node_template_info): Ditto.
	(trees_out::start): Ditto.
	(trees_out::decl_node): Ditto.
	(trees_in::read_var_def): Ditto.
	(set_instantiating_module): Ditto.
	* name-lookup.cc (maybe_record_mergeable_decl): Ditto.
	(consider_decl): Ditto.
	(maybe_add_fuzzy_decl): Ditto.
	* pt.cc (convert_nontype_argument): Ditto.
	* semantics.cc (handle_omp_array_sections_1): Ditto.
	(finish_omp_clauses): Ditto.
	(finish_omp_target_clauses_r): Ditto.
	(is_this_parameter): Ditto.
	* tree.cc (build_cplus_array_type): Ditto.
	(is_this_expression): Ditto.
	* typeck.cc (do_warn_enum_conversions): Ditto.
	* typeck2.cc (store_init_value): Ditto.
	(check_narrowing): Ditto.
---
 gcc/cp/call.cc             | 42 +++++++++++++++++++-------------------
 gcc/cp/class.cc            |  2 +-
 gcc/cp/coroutines.cc       |  2 +-
 gcc/cp/cp-tree.h           |  4 ++--
 gcc/cp/cvt.cc              |  2 +-
 gcc/cp/cxx-pretty-print.cc |  2 +-
 gcc/cp/decl.cc             |  4 ++--
 gcc/cp/error.cc            |  2 +-
 gcc/cp/lambda.cc           |  2 +-
 gcc/cp/mangle.cc           |  2 +-
 gcc/cp/method.cc           |  2 +-
 gcc/cp/module.cc           | 12 +++++------
 gcc/cp/name-lookup.cc      |  6 +++---
 gcc/cp/pt.cc               |  2 +-
 gcc/cp/semantics.cc        | 24 +++++++++++-----------
 gcc/cp/tree.cc             |  4 ++--
 gcc/cp/typeck.cc           |  4 ++--
 gcc/cp/typeck2.cc          | 10 ++++-----
 18 files changed, 64 insertions(+), 64 deletions(-)
  

Comments

Patrick Palka June 1, 2023, 3:24 p.m. UTC | #1
On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
>
> gcc/cp/ChangeLog:
>
>         * call.cc (promoted_arithmetic_type_p): Use _P defines from tree.h.
>         (build_conditional_expr): Ditto.
>         (convert_like_internal): Ditto.
>         (convert_arg_to_ellipsis): Ditto.
>         (build_over_call): Ditto.
>         (compare_ics): Ditto.
>         * class.cc (is_empty_base_ref): Ditto.
>         * coroutines.cc (rewrite_param_uses): Ditto.
>         * cp-tree.h (DECL_DISCRIMINATOR_P): Ditto.
>         (ARITHMETIC_TYPE_P): Ditto.
>         * cvt.cc (ocp_convert): Ditto.
>         * cxx-pretty-print.cc (pp_cxx_template_argument_list): Ditto.
>         * decl.cc (layout_var_decl): Ditto.
>         (get_tuple_size): Ditto.
>         * error.cc (dump_simple_decl): Ditto.
>         * lambda.cc (start_lambda_scope): Ditto.
>         * mangle.cc (write_template_arg): Ditto.
>         * method.cc (spaceship_comp_cat): Ditto.
>         * module.cc (node_template_info): Ditto.
>         (trees_out::start): Ditto.
>         (trees_out::decl_node): Ditto.
>         (trees_in::read_var_def): Ditto.
>         (set_instantiating_module): Ditto.
>         * name-lookup.cc (maybe_record_mergeable_decl): Ditto.
>         (consider_decl): Ditto.
>         (maybe_add_fuzzy_decl): Ditto.
>         * pt.cc (convert_nontype_argument): Ditto.
>         * semantics.cc (handle_omp_array_sections_1): Ditto.
>         (finish_omp_clauses): Ditto.
>         (finish_omp_target_clauses_r): Ditto.
>         (is_this_parameter): Ditto.
>         * tree.cc (build_cplus_array_type): Ditto.
>         (is_this_expression): Ditto.
>         * typeck.cc (do_warn_enum_conversions): Ditto.
>         * typeck2.cc (store_init_value): Ditto.
>         (check_narrowing): Ditto.
> ---
>  gcc/cp/call.cc             | 42 +++++++++++++++++++-------------------
>  gcc/cp/class.cc            |  2 +-
>  gcc/cp/coroutines.cc       |  2 +-
>  gcc/cp/cp-tree.h           |  4 ++--
>  gcc/cp/cvt.cc              |  2 +-
>  gcc/cp/cxx-pretty-print.cc |  2 +-
>  gcc/cp/decl.cc             |  4 ++--
>  gcc/cp/error.cc            |  2 +-
>  gcc/cp/lambda.cc           |  2 +-
>  gcc/cp/mangle.cc           |  2 +-
>  gcc/cp/method.cc           |  2 +-
>  gcc/cp/module.cc           | 12 +++++------
>  gcc/cp/name-lookup.cc      |  6 +++---
>  gcc/cp/pt.cc               |  2 +-
>  gcc/cp/semantics.cc        | 24 +++++++++++-----------
>  gcc/cp/tree.cc             |  4 ++--
>  gcc/cp/typeck.cc           |  4 ++--
>  gcc/cp/typeck2.cc          | 10 ++++-----
>  18 files changed, 64 insertions(+), 64 deletions(-)
>
> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
> index 2a06520c0c1..6e13d17f6b8 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -2746,7 +2746,7 @@ promoted_arithmetic_type_p (tree type)
>       integral types plus floating types.  */
>    return ((CP_INTEGRAL_TYPE_P (type)
>            && same_type_p (type_promotes_to (type), type))
> -         || TREE_CODE (type) == REAL_TYPE);
> +         || SCALAR_FLOAT_TYPE_P (type));
>  }
>
>  /* Create any builtin operator overload candidates for the operator in
> @@ -5759,10 +5759,10 @@ build_conditional_expr (const op_location_t &loc,
>    if ((TREE_CODE (arg2) == EXCESS_PRECISION_EXPR
>         || TREE_CODE (arg3) == EXCESS_PRECISION_EXPR)
>        && (TREE_CODE (arg2_type) == INTEGER_TYPE
> -         || TREE_CODE (arg2_type) == REAL_TYPE
> +         || SCALAR_FLOAT_TYPE_P (arg2_type)
>           || TREE_CODE (arg2_type) == COMPLEX_TYPE)
>        && (TREE_CODE (arg3_type) == INTEGER_TYPE
> -         || TREE_CODE (arg3_type) == REAL_TYPE
> +         || SCALAR_FLOAT_TYPE_P (arg3_type)
>           || TREE_CODE (arg3_type) == COMPLEX_TYPE))
>      {
>        semantic_result_type
> @@ -5775,8 +5775,8 @@ build_conditional_expr (const op_location_t &loc,
>             t1 = TREE_TYPE (t1);
>           if (TREE_CODE (t2) == COMPLEX_TYPE)
>             t2 = TREE_TYPE (t2);
> -         gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
> -                              && TREE_CODE (t2) == REAL_TYPE
> +         gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
> +                              && SCALAR_FLOAT_TYPE_P (t2)
>                                && (extended_float_type_p (t1)
>                                    || extended_float_type_p (t2))
>                                && cp_compare_floating_point_conversion_ranks
> @@ -6127,8 +6127,8 @@ build_conditional_expr (const op_location_t &loc,
>             t1 = TREE_TYPE (t1);
>           if (TREE_CODE (t2) == COMPLEX_TYPE)
>             t2 = TREE_TYPE (t2);
> -         gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
> -                              && TREE_CODE (t2) == REAL_TYPE
> +         gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
> +                              && SCALAR_FLOAT_TYPE_P (t2)
>                                && (extended_float_type_p (t1)
>                                    || extended_float_type_p (t2))
>                                && cp_compare_floating_point_conversion_ranks
> @@ -6147,8 +6147,8 @@ build_conditional_expr (const op_location_t &loc,
>             t1 = TREE_TYPE (t1);
>           if (TREE_CODE (t2) == COMPLEX_TYPE)
>             t2 = TREE_TYPE (t2);
> -         gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
> -                              && TREE_CODE (t2) == REAL_TYPE
> +         gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
> +                              && SCALAR_FLOAT_TYPE_P (t2)
>                                && (extended_float_type_p (t1)
>                                    || extended_float_type_p (t2))
>                                && cp_compare_floating_point_conversion_ranks
> @@ -6185,8 +6185,8 @@ build_conditional_expr (const op_location_t &loc,
>        else if ((complain & tf_warning)
>                && warn_deprecated_enum_float_conv
>                && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE
> -                   && TREE_CODE (arg3_type) == REAL_TYPE)
> -                  || (TREE_CODE (arg2_type) == REAL_TYPE
> +                   && SCALAR_FLOAT_TYPE_P (arg3_type))
> +                  || (SCALAR_FLOAT_TYPE_P (arg2_type)
>                        && TREE_CODE (arg3_type) == ENUMERAL_TYPE)))
>         {
>           if (TREE_CODE (arg2_type) == ENUMERAL_TYPE)
> @@ -8321,8 +8321,8 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
>                                 "direct-initialization",
>                                 totype, TREE_TYPE (expr));
>
> -      if (TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
> -         && TREE_CODE (totype) == REAL_TYPE
> +      if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (expr))
> +         && SCALAR_FLOAT_TYPE_P (totype)
>           && (extended_float_type_p (TREE_TYPE (expr))
>               || extended_float_type_p (totype)))
>         switch (cp_compare_floating_point_conversion_ranks (TREE_TYPE (expr),
> @@ -8976,7 +8976,7 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
>       type that is subject to the floating-point promotion
>       (_conv.fpprom_), the value of the argument is converted to the
>       promoted type before the call.  */
> -  if (TREE_CODE (arg_type) == REAL_TYPE
> +  if (SCALAR_FLOAT_TYPE_P (arg_type)
>        && (TYPE_PRECISION (arg_type)
>           < TYPE_PRECISION (double_type_node))
>        && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (arg_type))
> @@ -9798,7 +9798,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
>               obj_arg = NULL_TREE;
>             }
>           /* Look through *(const T *)&obj.  */
> -         else if (obj_arg && TREE_CODE (obj_arg) == INDIRECT_REF)
> +         else if (obj_arg && INDIRECT_REF_P (obj_arg))
>             {
>               tree addr = TREE_OPERAND (obj_arg, 0);
>               STRIP_NOPS (addr);
> @@ -10462,7 +10462,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
>               obj_arg = NULL_TREE;
>             }
>           /* Look through *(const T *)&obj.  */
> -         else if (obj_arg && TREE_CODE (obj_arg) == INDIRECT_REF)
> +         else if (obj_arg && INDIRECT_REF_P (obj_arg))
>             {
>               tree addr = TREE_OPERAND (obj_arg, 0);
>               STRIP_NOPS (addr);
> @@ -12199,7 +12199,7 @@ compare_ics (conversion *ics1, conversion *ics2)
>         std::swap (fp3, t3);
>        }
>      if (TYPE_MAIN_VARIANT (fp1) == TYPE_MAIN_VARIANT (fp3)
> -       && TREE_CODE (fp1) == REAL_TYPE
> +       && SCALAR_FLOAT_TYPE_P (fp1)
>         /* Only apply this rule if at least one of the 3 types is
>            extended floating-point type, otherwise keep them as
>            before for compatibility reasons with types like __float128.
> @@ -12207,15 +12207,15 @@ compare_ics (conversion *ics1, conversion *ics2)
>            ranks and so when just those 3 types are involved, this
>            rule doesn't trigger.  */
>         && (extended_float_type_p (fp1)
> -           || (TREE_CODE (fp2) == REAL_TYPE && extended_float_type_p (fp2))
> -           || (TREE_CODE (t3) == REAL_TYPE && extended_float_type_p (t3))))
> +           || (SCALAR_FLOAT_TYPE_P (fp2) && extended_float_type_p (fp2))
> +           || (SCALAR_FLOAT_TYPE_P (t3) && extended_float_type_p (t3))))
>        {
>         if (TREE_CODE (fp2) != REAL_TYPE)
>           {
>             ret = -ret;
>             std::swap (fp2, t3);
>           }
> -       if (TREE_CODE (fp2) == REAL_TYPE)
> +       if (SCALAR_FLOAT_TYPE_P (fp2))
>           {
>             /* cp_compare_floating_point_conversion_ranks returns -1, 0 or 1
>                if the conversion rank is equal (-1 or 1 if the subrank is
> @@ -12242,7 +12242,7 @@ compare_ics (conversion *ics1, conversion *ics2)
>                      FP1 <-> T3 conversion is better.  */
>                   return -ret;
>               }
> -           else if (TREE_CODE (t3) == REAL_TYPE
> +           else if (SCALAR_FLOAT_TYPE_P (t3)
>                      && IN_RANGE (cp_compare_floating_point_conversion_ranks
>                                                                 (fp1, t3),
>                                   -1, 1))
> diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
> index 68b62086340..bc84f4f731a 100644
> --- a/gcc/cp/class.cc
> +++ b/gcc/cp/class.cc
> @@ -673,7 +673,7 @@ convert_to_base_statically (tree expr, tree base)
>  bool
>  is_empty_base_ref (tree expr)
>  {
> -  if (TREE_CODE (expr) == INDIRECT_REF)
> +  if (INDIRECT_REF_P (expr))
>      expr = TREE_OPERAND (expr, 0);
>    if (TREE_CODE (expr) != NOP_EXPR)
>      return false;
> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
> index 59a240ebd40..3493d3c6ed3 100644
> --- a/gcc/cp/coroutines.cc
> +++ b/gcc/cp/coroutines.cc
> @@ -3780,7 +3780,7 @@ rewrite_param_uses (tree *stmt, int *do_subtree ATTRIBUTE_UNUSED, void *d)
>    param_frame_data *data = (param_frame_data *) d;
>
>    /* For lambda closure content, we have to look specifically.  */
> -  if (TREE_CODE (*stmt) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*stmt))
> +  if (VAR_P (*stmt) && DECL_HAS_VALUE_EXPR_P (*stmt))
>      {
>        tree t = DECL_VALUE_EXPR (*stmt);
>        return cp_walk_tree (&t, rewrite_param_uses, d, NULL);
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index 714b6d55f4f..a1b882f11fe 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -3189,7 +3189,7 @@ struct GTY(()) lang_decl {
>
>  /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
>  #define DECL_DISCRIMINATOR_P(NODE)                             \
> -  (((TREE_CODE (NODE) == VAR_DECL && TREE_STATIC (NODE))       \
> +  (((VAR_P (NODE) && TREE_STATIC (NODE))       \
>      || DECL_IMPLICIT_TYPEDEF_P (NODE))                         \
>     && DECL_FUNCTION_SCOPE_P (NODE))
>
> @@ -4453,7 +4453,7 @@ get_vec_init_expr (tree t)
>     Keep these checks in ascending code order.  */
>  #define ARITHMETIC_TYPE_P(TYPE) \
>    (CP_INTEGRAL_TYPE_P (TYPE) \
> -   || TREE_CODE (TYPE) == REAL_TYPE \
> +   || SCALAR_FLOAT_TYPE_P (TYPE) \
>     || TREE_CODE (TYPE) == COMPLEX_TYPE)
>
>  /* [basic.types]
> diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc
> index 17827d06a4a..c6b52f07050 100644
> --- a/gcc/cp/cvt.cc
> +++ b/gcc/cp/cvt.cc
> @@ -810,7 +810,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
>           /* enum = enum, enum = int, enum = float, (enum)pointer are all
>              errors.  */
>           if (((INTEGRAL_OR_ENUMERATION_TYPE_P (intype)
> -               || TREE_CODE (intype) == REAL_TYPE)
> +               || SCALAR_FLOAT_TYPE_P (intype))
>                && ! (convtype & CONV_STATIC))
>               || TYPE_PTR_P (intype))
>             {
> diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
> index 4b547c77ef4..909a9dc917f 100644
> --- a/gcc/cp/cxx-pretty-print.cc
> +++ b/gcc/cp/cxx-pretty-print.cc
> @@ -1966,7 +1966,7 @@ pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t)
>           if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
>                                && TYPE_P (DECL_TEMPLATE_RESULT (arg))))
>             pp->type_id (arg);
> -         else if (TREE_CODE (arg) == VAR_DECL && DECL_NTTP_OBJECT_P (arg))
> +         else if (VAR_P (arg) && DECL_NTTP_OBJECT_P (arg))
>             pp->expression (DECL_INITIAL (arg));
>           else
>             pp->expression (arg);
> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index 23a2b2fef0b..a672e4844f1 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -6349,7 +6349,7 @@ layout_var_decl (tree decl)
>        && !vec_safe_is_empty (CONSTRUCTOR_ELTS (DECL_INITIAL (decl)))
>        && DECL_SIZE (decl) != NULL_TREE
>        && TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST
> -      && TYPE_SIZE (type) != NULL_TREE
> +      && COMPLETE_TYPE_P (type)
>        && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
>        && tree_int_cst_equal (DECL_SIZE (decl), TYPE_SIZE (type)))
>      {
> @@ -8927,7 +8927,7 @@ get_tuple_size (tree type)
>      return NULL_TREE;
>    tree val = lookup_qualified_name (inst, value_identifier,
>                                     LOOK_want::NORMAL, /*complain*/false);
> -  if (TREE_CODE (val) == VAR_DECL || TREE_CODE (val) == CONST_DECL)
> +  if (VAR_P (val) || TREE_CODE (val) == CONST_DECL)
>      val = maybe_constant_value (val);
>    if (TREE_CODE (val) == INTEGER_CST)
>      return val;
> diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
> index 9b967ce409d..31319aa9e87 100644
> --- a/gcc/cp/error.cc
> +++ b/gcc/cp/error.cc
> @@ -1140,7 +1140,7 @@ dump_global_iord (cxx_pretty_printer *pp, tree t)
>  static void
>  dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
>  {
> -  if (TREE_CODE (t) == VAR_DECL && DECL_NTTP_OBJECT_P (t))
> +  if (VAR_P (t) && DECL_NTTP_OBJECT_P (t))
>      return dump_expr (pp, DECL_INITIAL (t), flags);
>
>    if (flags & TFF_DECL_SPECIFIERS)
> diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
> index 9925209b2ed..a359bc6ee8d 100644
> --- a/gcc/cp/lambda.cc
> +++ b/gcc/cp/lambda.cc
> @@ -1474,7 +1474,7 @@ void
>  start_lambda_scope (tree decl)
>  {
>    gcc_checking_assert (decl);
> -  if (current_function_decl && TREE_CODE (decl) == VAR_DECL)
> +  if (current_function_decl && VAR_P (decl))
>      // If we're inside a function, we ignore variable scope.  Don't push.
>      lambda_scope.nesting++;
>    else
> diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
> index a235f23459d..826c5e76c1d 100644
> --- a/gcc/cp/mangle.cc
> +++ b/gcc/cp/mangle.cc
> @@ -3793,7 +3793,7 @@ write_template_arg (tree node)
>         }
>      }
>
> -  if (TREE_CODE (node) == VAR_DECL && DECL_NTTP_OBJECT_P (node))
> +  if (VAR_P (node) && DECL_NTTP_OBJECT_P (node))
>      /* We want to mangle the argument, not the var we stored it in.  */
>      node = tparm_object_argument (node);
>
> diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
> index 00eae56eb5b..cbcc7948b37 100644
> --- a/gcc/cp/method.cc
> +++ b/gcc/cp/method.cc
> @@ -1048,7 +1048,7 @@ spaceship_comp_cat (tree optype)
>  {
>    if (INTEGRAL_OR_ENUMERATION_TYPE_P (optype) || TYPE_PTROBV_P (optype))
>      return cc_strong_ordering;
> -  else if (TREE_CODE (optype) == REAL_TYPE)
> +  else if (SCALAR_FLOAT_TYPE_P (optype))
>      return cc_partial_ordering;
>
>    /* ??? should vector <=> produce a vector of one of the above?  */
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index ac2fe66b080..ecde98d69b4 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -4042,7 +4042,7 @@ node_template_info (tree decl, int &use)
>         }
>      }
>    else if (DECL_LANG_SPECIFIC (decl)
> -          && (TREE_CODE (decl) == VAR_DECL
> +          && (VAR_P (decl)
>                || TREE_CODE (decl) == TYPE_DECL
>                || TREE_CODE (decl) == FUNCTION_DECL
>                || TREE_CODE (decl) == FIELD_DECL
> @@ -5151,7 +5151,7 @@ trees_out::start (tree t, bool code_streamed)
>    switch (TREE_CODE (t))
>      {
>      default:
> -      if (TREE_CODE_CLASS (TREE_CODE (t)) == tcc_vl_exp)
> +      if (VL_EXP_CLASS_P (t))
>         u (VL_EXP_OPERAND_LENGTH (t));
>        break;
>
> @@ -8551,7 +8551,7 @@ trees_out::decl_node (tree decl, walk_kind ref)
>         {
>         tinfo:
>           /* A typeinfo, tt_tinfo_typedef or tt_tinfo_var.  */
> -         bool is_var = TREE_CODE (decl) == VAR_DECL;
> +         bool is_var = VAR_P (decl);
>           tree type = TREE_TYPE (decl);
>           unsigned ix = get_pseudo_tinfo_index (type);
>           if (streaming_p ())
> @@ -8651,7 +8651,7 @@ trees_out::decl_node (tree decl, walk_kind ref)
>       Mostly things that can be defined outside of their (original
>       declaration) context.  */
>    gcc_checking_assert (TREE_CODE (decl) == TEMPLATE_DECL
> -                      || TREE_CODE (decl) == VAR_DECL
> +                      || VAR_P (decl)
>                        || TREE_CODE (decl) == FUNCTION_DECL
>                        || TREE_CODE (decl) == TYPE_DECL
>                        || TREE_CODE (decl) == USING_DECL
> @@ -11702,7 +11702,7 @@ bool
>  trees_in::read_var_def (tree decl, tree maybe_template)
>  {
>    /* Do not mark the virtual table entries as used.  */
> -  bool vtable = TREE_CODE (decl) == VAR_DECL && DECL_VTABLE_OR_VTT_P (decl);
> +  bool vtable = VAR_P (decl) && DECL_VTABLE_OR_VTT_P (decl);
>    unused += vtable;
>    tree init = tree_node ();
>    tree dyn_init = init ? NULL_TREE : tree_node ();
> @@ -18776,7 +18776,7 @@ void
>  set_instantiating_module (tree decl)
>  {
>    gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
> -             || TREE_CODE (decl) == VAR_DECL
> +             || VAR_P (decl)
>               || TREE_CODE (decl) == TYPE_DECL
>               || TREE_CODE (decl) == CONCEPT_DECL
>               || TREE_CODE (decl) == TEMPLATE_DECL
> diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
> index ad03141df43..eb5c333b5ea 100644
> --- a/gcc/cp/name-lookup.cc
> +++ b/gcc/cp/name-lookup.cc
> @@ -3488,7 +3488,7 @@ maybe_record_mergeable_decl (tree *slot, tree name, tree decl)
>
>    tree not_tmpl = STRIP_TEMPLATE (decl);
>    if ((TREE_CODE (not_tmpl) == FUNCTION_DECL
> -       || TREE_CODE (not_tmpl) == VAR_DECL)
> +       || VAR_P (not_tmpl))
>        && DECL_THIS_STATIC (not_tmpl))
>      /* Internal linkage.  */
>      return;
> @@ -6932,7 +6932,7 @@ consider_decl (tree decl,  best_match <tree, const char *> &bm,
>  {
>    /* Skip compiler-generated variables (e.g. __for_begin/__for_end
>       within range for).  */
> -  if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl))
> +  if (VAR_P (decl) && DECL_ARTIFICIAL (decl))
>      return;
>
>    tree suggestion = DECL_NAME (decl);
> @@ -6967,7 +6967,7 @@ maybe_add_fuzzy_decl (auto_vec<tree> &vec, tree decl)
>  {
>    /* Skip compiler-generated variables (e.g. __for_begin/__for_end
>       within range for).  */
> -  if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl))
> +  if (VAR_P (decl) && DECL_ARTIFICIAL (decl))
>      return false;
>
>    tree suggestion = DECL_NAME (decl);
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 696df2bdd9f..16d658e3c6a 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -7487,7 +7487,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
>       integral promotions (_conv.prom_) and integral conversions
>       (_conv.integral_) are applied.  */
>    if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
> -      || TREE_CODE (type) == REAL_TYPE)
> +      || SCALAR_FLOAT_TYPE_P (type))
>      {
>        if (cxx_dialect < cxx11)
>         {
> diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
> index 13c6582b628..05df6282302 100644
> --- a/gcc/cp/semantics.cc
> +++ b/gcc/cp/semantics.cc
> @@ -5169,7 +5169,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
>           && TREE_CODE (TREE_OPERAND (t, 0)) == COMPONENT_REF)
>         t = TREE_OPERAND (t, 0);
>        ret = t;
> -      while (TREE_CODE (t) == INDIRECT_REF)
> +      while (INDIRECT_REF_P (t))
>         {
>           t = TREE_OPERAND (t, 0);
>           STRIP_NOPS (t);
> @@ -5206,7 +5206,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
>                 }
>               t = TREE_OPERAND (t, 0);
>               while (TREE_CODE (t) == MEM_REF
> -                    || TREE_CODE (t) == INDIRECT_REF
> +                    || INDIRECT_REF_P (t)
>                      || TREE_CODE (t) == ARRAY_REF)
>                 {
>                   t = TREE_OPERAND (t, 0);
> @@ -8097,7 +8097,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>                           if (REFERENCE_REF_P (t))
>                             t = TREE_OPERAND (t, 0);
>                           if (TREE_CODE (t) == MEM_REF
> -                             || TREE_CODE (t) == INDIRECT_REF)
> +                             || INDIRECT_REF_P (t))
>                             {
>                               t = TREE_OPERAND (t, 0);
>                               STRIP_NOPS (t);
> @@ -8182,7 +8182,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>                   && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH)
>                 OMP_CLAUSE_DECL (c) = t;
>             }
> -         while (TREE_CODE (t) == INDIRECT_REF
> +         while (INDIRECT_REF_P (t)
>                  || TREE_CODE (t) == ARRAY_REF)
>             {
>               t = TREE_OPERAND (t, 0);
> @@ -8201,7 +8201,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>             remove = true;
>           indir_component_ref_p = false;
>           if (TREE_CODE (t) == COMPONENT_REF
> -             && (TREE_CODE (TREE_OPERAND (t, 0)) == INDIRECT_REF
> +             && (INDIRECT_REF_P (TREE_OPERAND (t, 0))
>                   || TREE_CODE (TREE_OPERAND (t, 0)) == ARRAY_REF))
>             {
>               t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
> @@ -8255,7 +8255,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>                         t = TREE_OPERAND (t, 0);
>                     }
>                   while (TREE_CODE (t) == MEM_REF
> -                        || TREE_CODE (t) == INDIRECT_REF
> +                        || INDIRECT_REF_P (t)
>                          || TREE_CODE (t) == ARRAY_REF)
>                     {
>                       t = TREE_OPERAND (t, 0);
> @@ -8706,7 +8706,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>                   t = OMP_CLAUSE_DECL (c);
>                   while (TREE_CODE (t) == TREE_LIST)
>                     t = TREE_CHAIN (t);
> -                 while (TREE_CODE (t) == INDIRECT_REF
> +                 while (INDIRECT_REF_P (t)
>                          || TREE_CODE (t) == ARRAY_REF)
>                     t = TREE_OPERAND (t, 0);
>                 }
> @@ -9021,7 +9021,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>             {
>               t = OMP_CLAUSE_DECL (c);
>               while (handled_component_p (t)
> -                    || TREE_CODE (t) == INDIRECT_REF
> +                    || INDIRECT_REF_P (t)
>                      || TREE_CODE (t) == ADDR_EXPR
>                      || TREE_CODE (t) == MEM_REF
>                      || TREE_CODE (t) == NON_LVALUE_EXPR)
> @@ -9070,7 +9070,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
>                   if (TREE_CODE (t) == POINTER_PLUS_EXPR)
>                     t = TREE_OPERAND (t, 0);
>                   if (TREE_CODE (t) == ADDR_EXPR
> -                     || TREE_CODE (t) == INDIRECT_REF)
> +                     || INDIRECT_REF_P (t))
>                     t = TREE_OPERAND (t, 0);
>                   if (DECL_P (t))
>                     bitmap_clear_bit (&aligned_head, DECL_UID (t));
> @@ -9609,7 +9609,7 @@ finish_omp_target_clauses_r (tree *tp, int *walk_subtrees, void *ptr)
>       of DECL_VALUE_EXPRs during the target body walk seems the only way to
>       find them.  */
>    if (current_closure
> -      && (TREE_CODE (t) == VAR_DECL
> +      && (VAR_P (t)
>           || TREE_CODE (t) == PARM_DECL
>           || TREE_CODE (t) == RESULT_DECL)
>        && DECL_HAS_VALUE_EXPR_P (t)
> @@ -12362,8 +12362,8 @@ is_this_parameter (tree t)
>    if (!DECL_P (t) || DECL_NAME (t) != this_identifier)
>      return false;
>    gcc_assert (TREE_CODE (t) == PARM_DECL
> -             || (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
> -             || (cp_binding_oracle && TREE_CODE (t) == VAR_DECL));
> +             || (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
> +             || (cp_binding_oracle && VAR_P (t)));
>    return true;
>  }
>
> diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> index 131b212ff73..19dfb3ed782 100644
> --- a/gcc/cp/tree.cc
> +++ b/gcc/cp/tree.cc
> @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
>      }
>
>    /* Avoid spurious warnings with VLAs (c++/54583).  */
> -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))

Hmm, this change seems undesirable...

>      suppress_warning (TYPE_SIZE (t), OPT_Wunused);
>
>    /* Push these needs up to the ARRAY_TYPE so that initialization takes
> @@ -3911,7 +3911,7 @@ is_this_expression (tree t)
>  {
>    t = get_innermost_component (t);
>    /* See through deferences and no-op conversions.  */
> -  if (TREE_CODE (t) == INDIRECT_REF)
> +  if (INDIRECT_REF_P (t))
>      t = TREE_OPERAND (t, 0);
>    if (TREE_CODE (t) == NOP_EXPR)
>      t = TREE_OPERAND (t, 0);
> diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
> index 53ac925a092..a4ceb8a1703 100644
> --- a/gcc/cp/typeck.cc
> +++ b/gcc/cp/typeck.cc
> @@ -4996,8 +4996,8 @@ do_warn_enum_conversions (location_t loc, enum tree_code code, tree type0,
>         }
>      }
>    else if ((TREE_CODE (type0) == ENUMERAL_TYPE
> -           && TREE_CODE (type1) == REAL_TYPE)
> -          || (TREE_CODE (type0) == REAL_TYPE
> +           && SCALAR_FLOAT_TYPE_P (type1))
> +          || (SCALAR_FLOAT_TYPE_P (type0)
>                && TREE_CODE (type1) == ENUMERAL_TYPE))
>      {
>        const bool enum_first_p = TREE_CODE (type0) == ENUMERAL_TYPE;
> diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
> index bf03967a71f..6affdc73fb1 100644
> --- a/gcc/cp/typeck2.cc
> +++ b/gcc/cp/typeck2.cc
> @@ -907,7 +907,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
>       here it should have been digested into an actual value for the type.  */
>    gcc_checking_assert (TREE_CODE (value) != CONSTRUCTOR
>                        || processing_template_decl
> -                      || TREE_CODE (type) == VECTOR_TYPE
> +                      || VECTOR_TYPE_P (type)
>                        || !TREE_HAS_CONSTRUCTOR (value));
>
>    /* If the initializer is not a constant, fill in DECL_INITIAL with
> @@ -974,7 +974,7 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain,
>      return ok;
>
>    if (CP_INTEGRAL_TYPE_P (type)
> -      && TREE_CODE (ftype) == REAL_TYPE)
> +      && SCALAR_FLOAT_TYPE_P (ftype))
>      ok = false;
>    else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
>            && CP_INTEGRAL_TYPE_P (type))
> @@ -992,8 +992,8 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain,
>      }
>    /* [dcl.init.list]#7.2: "from long double to double or float, or from
>        double to float".  */
> -  else if (TREE_CODE (ftype) == REAL_TYPE
> -          && TREE_CODE (type) == REAL_TYPE)
> +  else if (SCALAR_FLOAT_TYPE_P (ftype)
> +          && SCALAR_FLOAT_TYPE_P (type))
>      {
>        if ((extended_float_type_p (ftype) || extended_float_type_p (type))
>           ? /* "from a floating-point type T to another floating-point type
> @@ -1030,7 +1030,7 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain,
>         }
>      }
>    else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
> -          && TREE_CODE (type) == REAL_TYPE)
> +          && SCALAR_FLOAT_TYPE_P (type))
>      {
>        ok = false;
>        if (TREE_CODE (init) == INTEGER_CST)
> --
> 2.30.2
>
  
Bernhard Reutner-Fischer June 1, 2023, 4:33 p.m. UTC | #2
On Thu, 1 Jun 2023 11:24:06 -0400
Patrick Palka <ppalka@redhat.com> wrote:

> On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

> > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > index 131b212ff73..19dfb3ed782 100644
> > --- a/gcc/cp/tree.cc
> > +++ b/gcc/cp/tree.cc
> > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
> >      }
> >
> >    /* Avoid spurious warnings with VLAs (c++/54583).  */
> > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))  
> 
> Hmm, this change seems undesirable...

mhm, yes that is misleading. I'll prepare a patch to revert this.
Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
that we'd want to revert.

thanks,
  
Bernhard Reutner-Fischer June 1, 2023, 6:10 p.m. UTC | #3
Hi David, Patrick,

On Thu, 1 Jun 2023 18:33:46 +0200
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:

> On Thu, 1 Jun 2023 11:24:06 -0400
> Patrick Palka <ppalka@redhat.com> wrote:
> 
> > On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> > Gcc-patches <gcc-patches@gcc.gnu.org> wrote:  
> 
> > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > > index 131b212ff73..19dfb3ed782 100644
> > > --- a/gcc/cp/tree.cc
> > > +++ b/gcc/cp/tree.cc
> > > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
> > >      }
> > >
> > >    /* Avoid spurious warnings with VLAs (c++/54583).  */
> > > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))    
> > 
> > Hmm, this change seems undesirable...  
> 
> mhm, yes that is misleading. I'll prepare a patch to revert this.
> Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
> that we'd want to revert.

Sorry for that!
I'd revert the hunk above and the one in gcc-rich-location.cc
(maybe_range_label_for_tree_type_mismatch::get_text), please see
attached. Bootstrap running, ok for trunk if it passes?

thanks,
From 322bce380144b5199cca5775f7a3f0fb30a219ae Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Date: Thu, 1 Jun 2023 19:44:19 +0200
Subject: [PATCH] c++, analyzer: Expand CAN_HAVE_LOCATION_P macro.

r14-985-gca2007a9bb3074 used the collapsed macro definition
CAN_HAVE_LOCATION_P in gcc-rich-location.cc and r14-977-g8861c80733da5c
in c++'s build_cplus_array_type ().
However, although otherwise correct, the usage of CAN_HAVE_LOCATION_P
in these two spots is misleading, so this patch reverts aforementioned
two hunks.

gcc/cp/ChangeLog:

	* tree.cc (build_cplus_array_type): Revert using the macro
	CAN_HAVE_LOCATION_P.

gcc/ChangeLog:

	* gcc-rich-location.cc (maybe_range_label_for_tree_type_mismatch::get_text):
	Revert using the macro CAN_HAVE_LOCATION_P.
---
 gcc/cp/tree.cc           | 2 +-
 gcc/gcc-rich-location.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 19dfb3ed782..9363166152a 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
     }
 
   /* Avoid spurious warnings with VLAs (c++/54583).  */
-  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
+  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
     suppress_warning (TYPE_SIZE (t), OPT_Wunused);
 
   /* Push these needs up to the ARRAY_TYPE so that initialization takes
diff --git a/gcc/gcc-rich-location.cc b/gcc/gcc-rich-location.cc
index edecf07f81e..d02a5144cc6 100644
--- a/gcc/gcc-rich-location.cc
+++ b/gcc/gcc-rich-location.cc
@@ -200,7 +200,7 @@ maybe_range_label_for_tree_type_mismatch::get_text (unsigned range_idx) const
   tree expr_type = TREE_TYPE (m_expr);
 
   tree other_type = NULL_TREE;
-  if (CAN_HAVE_LOCATION_P (m_other_expr))
+  if (m_other_expr && EXPR_P (m_other_expr))
     other_type = TREE_TYPE (m_other_expr);
 
   range_label_for_type_mismatch inner (expr_type, other_type);
  
Patrick Palka Aug. 2, 2023, 4:51 p.m. UTC | #4
On Thu, Jun 1, 2023 at 2:11 PM Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
>
> Hi David, Patrick,
>
> On Thu, 1 Jun 2023 18:33:46 +0200
> Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
>
> > On Thu, 1 Jun 2023 11:24:06 -0400
> > Patrick Palka <ppalka@redhat.com> wrote:
> >
> > > On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> > > Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >
> > > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > > > index 131b212ff73..19dfb3ed782 100644
> > > > --- a/gcc/cp/tree.cc
> > > > +++ b/gcc/cp/tree.cc
> > > > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
> > > >      }
> > > >
> > > >    /* Avoid spurious warnings with VLAs (c++/54583).  */
> > > > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > > > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
> > >
> > > Hmm, this change seems undesirable...
> >
> > mhm, yes that is misleading. I'll prepare a patch to revert this.
> > Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
> > that we'd want to revert.
>
> Sorry for that!
> I'd revert the hunk above and the one in gcc-rich-location.cc
> (maybe_range_label_for_tree_type_mismatch::get_text), please see
> attached. Bootstrap running, ok for trunk if it passes?

LGTM!

>
> thanks,
  
Jason Merrill Aug. 8, 2023, 8:31 p.m. UTC | #5
On 8/2/23 12:51, Patrick Palka via Gcc-patches wrote:
> On Thu, Jun 1, 2023 at 2:11 PM Bernhard Reutner-Fischer
> <rep.dot.nop@gmail.com> wrote:
>>
>> Hi David, Patrick,
>>
>> On Thu, 1 Jun 2023 18:33:46 +0200
>> Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
>>
>>> On Thu, 1 Jun 2023 11:24:06 -0400
>>> Patrick Palka <ppalka@redhat.com> wrote:
>>>
>>>> On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
>>>> Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>>
>>>>> diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
>>>>> index 131b212ff73..19dfb3ed782 100644
>>>>> --- a/gcc/cp/tree.cc
>>>>> +++ b/gcc/cp/tree.cc
>>>>> @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
>>>>>       }
>>>>>
>>>>>     /* Avoid spurious warnings with VLAs (c++/54583).  */
>>>>> -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
>>>>> +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
>>>>
>>>> Hmm, this change seems undesirable...
>>>
>>> mhm, yes that is misleading. I'll prepare a patch to revert this.
>>> Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
>>> that we'd want to revert.
>>
>> Sorry for that!
>> I'd revert the hunk above and the one in gcc-rich-location.cc
>> (maybe_range_label_for_tree_type_mismatch::get_text), please see
>> attached. Bootstrap running, ok for trunk if it passes?
> 
> LGTM!

Yes, OK.

Jason
  
Bernhard Reutner-Fischer Nov. 15, 2023, 5:42 p.m. UTC | #6
On Tue, 8 Aug 2023 16:31:39 -0400
Jason Merrill <jason@redhat.com> wrote:

> On 8/2/23 12:51, Patrick Palka via Gcc-patches wrote:
> > On Thu, Jun 1, 2023 at 2:11 PM Bernhard Reutner-Fischer
> > <rep.dot.nop@gmail.com> wrote:  
> >>
> >> Hi David, Patrick,
> >>
> >> On Thu, 1 Jun 2023 18:33:46 +0200
> >> Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> >>  
> >>> On Thu, 1 Jun 2023 11:24:06 -0400
> >>> Patrick Palka <ppalka@redhat.com> wrote:
> >>>  
> >>>> On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> >>>> Gcc-patches <gcc-patches@gcc.gnu.org> wrote:  
> >>>  
> >>>>> diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> >>>>> index 131b212ff73..19dfb3ed782 100644
> >>>>> --- a/gcc/cp/tree.cc
> >>>>> +++ b/gcc/cp/tree.cc
> >>>>> @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
> >>>>>       }
> >>>>>
> >>>>>     /* Avoid spurious warnings with VLAs (c++/54583).  */
> >>>>> -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> >>>>> +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))  
> >>>>
> >>>> Hmm, this change seems undesirable...  
> >>>
> >>> mhm, yes that is misleading. I'll prepare a patch to revert this.
> >>> Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
> >>> that we'd want to revert.  
> >>
> >> Sorry for that!
> >> I'd revert the hunk above and the one in gcc-rich-location.cc
> >> (maybe_range_label_for_tree_type_mismatch::get_text), please see
> >> attached. Bootstrap running, ok for trunk if it passes?  
> > 
> > LGTM!  
> 
> Yes, OK.

Now applied as r14-5508 (186331063dfbcf1eacb445c473d92634c9baa90f)

thanks
  

Patch

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 2a06520c0c1..6e13d17f6b8 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -2746,7 +2746,7 @@  promoted_arithmetic_type_p (tree type)
      integral types plus floating types.  */
   return ((CP_INTEGRAL_TYPE_P (type)
 	   && same_type_p (type_promotes_to (type), type))
-	  || TREE_CODE (type) == REAL_TYPE);
+	  || SCALAR_FLOAT_TYPE_P (type));
 }
 
 /* Create any builtin operator overload candidates for the operator in
@@ -5759,10 +5759,10 @@  build_conditional_expr (const op_location_t &loc,
   if ((TREE_CODE (arg2) == EXCESS_PRECISION_EXPR
        || TREE_CODE (arg3) == EXCESS_PRECISION_EXPR)
       && (TREE_CODE (arg2_type) == INTEGER_TYPE
-	  || TREE_CODE (arg2_type) == REAL_TYPE
+	  || SCALAR_FLOAT_TYPE_P (arg2_type)
 	  || TREE_CODE (arg2_type) == COMPLEX_TYPE)
       && (TREE_CODE (arg3_type) == INTEGER_TYPE
-	  || TREE_CODE (arg3_type) == REAL_TYPE
+	  || SCALAR_FLOAT_TYPE_P (arg3_type)
 	  || TREE_CODE (arg3_type) == COMPLEX_TYPE))
     {
       semantic_result_type
@@ -5775,8 +5775,8 @@  build_conditional_expr (const op_location_t &loc,
 	    t1 = TREE_TYPE (t1);
 	  if (TREE_CODE (t2) == COMPLEX_TYPE)
 	    t2 = TREE_TYPE (t2);
-	  gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-			       && TREE_CODE (t2) == REAL_TYPE
+	  gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+			       && SCALAR_FLOAT_TYPE_P (t2)
 			       && (extended_float_type_p (t1)
 				   || extended_float_type_p (t2))
 			       && cp_compare_floating_point_conversion_ranks
@@ -6127,8 +6127,8 @@  build_conditional_expr (const op_location_t &loc,
 	    t1 = TREE_TYPE (t1);
 	  if (TREE_CODE (t2) == COMPLEX_TYPE)
 	    t2 = TREE_TYPE (t2);
-	  gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-			       && TREE_CODE (t2) == REAL_TYPE
+	  gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+			       && SCALAR_FLOAT_TYPE_P (t2)
 			       && (extended_float_type_p (t1)
 				   || extended_float_type_p (t2))
 			       && cp_compare_floating_point_conversion_ranks
@@ -6147,8 +6147,8 @@  build_conditional_expr (const op_location_t &loc,
 	    t1 = TREE_TYPE (t1);
 	  if (TREE_CODE (t2) == COMPLEX_TYPE)
 	    t2 = TREE_TYPE (t2);
-	  gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-			       && TREE_CODE (t2) == REAL_TYPE
+	  gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+			       && SCALAR_FLOAT_TYPE_P (t2)
 			       && (extended_float_type_p (t1)
 				   || extended_float_type_p (t2))
 			       && cp_compare_floating_point_conversion_ranks
@@ -6185,8 +6185,8 @@  build_conditional_expr (const op_location_t &loc,
       else if ((complain & tf_warning)
 	       && warn_deprecated_enum_float_conv
 	       && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE
-		    && TREE_CODE (arg3_type) == REAL_TYPE)
-		   || (TREE_CODE (arg2_type) == REAL_TYPE
+		    && SCALAR_FLOAT_TYPE_P (arg3_type))
+		   || (SCALAR_FLOAT_TYPE_P (arg2_type)
 		       && TREE_CODE (arg3_type) == ENUMERAL_TYPE)))
 	{
 	  if (TREE_CODE (arg2_type) == ENUMERAL_TYPE)
@@ -8321,8 +8321,8 @@  convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
 				"direct-initialization",
 				totype, TREE_TYPE (expr));
 
-      if (TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
-	  && TREE_CODE (totype) == REAL_TYPE
+      if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (expr))
+	  && SCALAR_FLOAT_TYPE_P (totype)
 	  && (extended_float_type_p (TREE_TYPE (expr))
 	      || extended_float_type_p (totype)))
 	switch (cp_compare_floating_point_conversion_ranks (TREE_TYPE (expr),
@@ -8976,7 +8976,7 @@  convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
      type that is subject to the floating-point promotion
      (_conv.fpprom_), the value of the argument is converted to the
      promoted type before the call.  */
-  if (TREE_CODE (arg_type) == REAL_TYPE
+  if (SCALAR_FLOAT_TYPE_P (arg_type)
       && (TYPE_PRECISION (arg_type)
 	  < TYPE_PRECISION (double_type_node))
       && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (arg_type))
@@ -9798,7 +9798,7 @@  build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 	      obj_arg = NULL_TREE;
 	    }
 	  /* Look through *(const T *)&obj.  */
-	  else if (obj_arg && TREE_CODE (obj_arg) == INDIRECT_REF)
+	  else if (obj_arg && INDIRECT_REF_P (obj_arg))
 	    {
 	      tree addr = TREE_OPERAND (obj_arg, 0);
 	      STRIP_NOPS (addr);
@@ -10462,7 +10462,7 @@  build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 	      obj_arg = NULL_TREE;
 	    }
 	  /* Look through *(const T *)&obj.  */
-	  else if (obj_arg && TREE_CODE (obj_arg) == INDIRECT_REF)
+	  else if (obj_arg && INDIRECT_REF_P (obj_arg))
 	    {
 	      tree addr = TREE_OPERAND (obj_arg, 0);
 	      STRIP_NOPS (addr);
@@ -12199,7 +12199,7 @@  compare_ics (conversion *ics1, conversion *ics2)
 	std::swap (fp3, t3);
       }
     if (TYPE_MAIN_VARIANT (fp1) == TYPE_MAIN_VARIANT (fp3)
-	&& TREE_CODE (fp1) == REAL_TYPE
+	&& SCALAR_FLOAT_TYPE_P (fp1)
 	/* Only apply this rule if at least one of the 3 types is
 	   extended floating-point type, otherwise keep them as
 	   before for compatibility reasons with types like __float128.
@@ -12207,15 +12207,15 @@  compare_ics (conversion *ics1, conversion *ics2)
 	   ranks and so when just those 3 types are involved, this
 	   rule doesn't trigger.  */
 	&& (extended_float_type_p (fp1)
-	    || (TREE_CODE (fp2) == REAL_TYPE && extended_float_type_p (fp2))
-	    || (TREE_CODE (t3) == REAL_TYPE && extended_float_type_p (t3))))
+	    || (SCALAR_FLOAT_TYPE_P (fp2) && extended_float_type_p (fp2))
+	    || (SCALAR_FLOAT_TYPE_P (t3) && extended_float_type_p (t3))))
       {
 	if (TREE_CODE (fp2) != REAL_TYPE)
 	  {
 	    ret = -ret;
 	    std::swap (fp2, t3);
 	  }
-	if (TREE_CODE (fp2) == REAL_TYPE)
+	if (SCALAR_FLOAT_TYPE_P (fp2))
 	  {
 	    /* cp_compare_floating_point_conversion_ranks returns -1, 0 or 1
 	       if the conversion rank is equal (-1 or 1 if the subrank is
@@ -12242,7 +12242,7 @@  compare_ics (conversion *ics1, conversion *ics2)
 		     FP1 <-> T3 conversion is better.  */
 		  return -ret;
 	      }
-	    else if (TREE_CODE (t3) == REAL_TYPE
+	    else if (SCALAR_FLOAT_TYPE_P (t3)
 		     && IN_RANGE (cp_compare_floating_point_conversion_ranks
 								(fp1, t3),
 				  -1, 1))
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 68b62086340..bc84f4f731a 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -673,7 +673,7 @@  convert_to_base_statically (tree expr, tree base)
 bool
 is_empty_base_ref (tree expr)
 {
-  if (TREE_CODE (expr) == INDIRECT_REF)
+  if (INDIRECT_REF_P (expr))
     expr = TREE_OPERAND (expr, 0);
   if (TREE_CODE (expr) != NOP_EXPR)
     return false;
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 59a240ebd40..3493d3c6ed3 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3780,7 +3780,7 @@  rewrite_param_uses (tree *stmt, int *do_subtree ATTRIBUTE_UNUSED, void *d)
   param_frame_data *data = (param_frame_data *) d;
 
   /* For lambda closure content, we have to look specifically.  */
-  if (TREE_CODE (*stmt) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*stmt))
+  if (VAR_P (*stmt) && DECL_HAS_VALUE_EXPR_P (*stmt))
     {
       tree t = DECL_VALUE_EXPR (*stmt);
       return cp_walk_tree (&t, rewrite_param_uses, d, NULL);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 714b6d55f4f..a1b882f11fe 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3189,7 +3189,7 @@  struct GTY(()) lang_decl {
 
 /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
 #define DECL_DISCRIMINATOR_P(NODE)				\
-  (((TREE_CODE (NODE) == VAR_DECL && TREE_STATIC (NODE))	\
+  (((VAR_P (NODE) && TREE_STATIC (NODE))	\
     || DECL_IMPLICIT_TYPEDEF_P (NODE))				\
    && DECL_FUNCTION_SCOPE_P (NODE))
 
@@ -4453,7 +4453,7 @@  get_vec_init_expr (tree t)
    Keep these checks in ascending code order.  */
 #define ARITHMETIC_TYPE_P(TYPE) \
   (CP_INTEGRAL_TYPE_P (TYPE) \
-   || TREE_CODE (TYPE) == REAL_TYPE \
+   || SCALAR_FLOAT_TYPE_P (TYPE) \
    || TREE_CODE (TYPE) == COMPLEX_TYPE)
 
 /* [basic.types]
diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc
index 17827d06a4a..c6b52f07050 100644
--- a/gcc/cp/cvt.cc
+++ b/gcc/cp/cvt.cc
@@ -810,7 +810,7 @@  ocp_convert (tree type, tree expr, int convtype, int flags,
 	  /* enum = enum, enum = int, enum = float, (enum)pointer are all
 	     errors.  */
 	  if (((INTEGRAL_OR_ENUMERATION_TYPE_P (intype)
-		|| TREE_CODE (intype) == REAL_TYPE)
+		|| SCALAR_FLOAT_TYPE_P (intype))
 	       && ! (convtype & CONV_STATIC))
 	      || TYPE_PTR_P (intype))
 	    {
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index 4b547c77ef4..909a9dc917f 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -1966,7 +1966,7 @@  pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t)
 	  if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
 			       && TYPE_P (DECL_TEMPLATE_RESULT (arg))))
 	    pp->type_id (arg);
-	  else if (TREE_CODE (arg) == VAR_DECL && DECL_NTTP_OBJECT_P (arg))
+	  else if (VAR_P (arg) && DECL_NTTP_OBJECT_P (arg))
 	    pp->expression (DECL_INITIAL (arg));
 	  else
 	    pp->expression (arg);
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 23a2b2fef0b..a672e4844f1 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -6349,7 +6349,7 @@  layout_var_decl (tree decl)
       && !vec_safe_is_empty (CONSTRUCTOR_ELTS (DECL_INITIAL (decl)))
       && DECL_SIZE (decl) != NULL_TREE
       && TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST
-      && TYPE_SIZE (type) != NULL_TREE
+      && COMPLETE_TYPE_P (type)
       && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
       && tree_int_cst_equal (DECL_SIZE (decl), TYPE_SIZE (type)))
     {
@@ -8927,7 +8927,7 @@  get_tuple_size (tree type)
     return NULL_TREE;
   tree val = lookup_qualified_name (inst, value_identifier,
 				    LOOK_want::NORMAL, /*complain*/false);
-  if (TREE_CODE (val) == VAR_DECL || TREE_CODE (val) == CONST_DECL)
+  if (VAR_P (val) || TREE_CODE (val) == CONST_DECL)
     val = maybe_constant_value (val);
   if (TREE_CODE (val) == INTEGER_CST)
     return val;
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 9b967ce409d..31319aa9e87 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -1140,7 +1140,7 @@  dump_global_iord (cxx_pretty_printer *pp, tree t)
 static void
 dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
 {
-  if (TREE_CODE (t) == VAR_DECL && DECL_NTTP_OBJECT_P (t))
+  if (VAR_P (t) && DECL_NTTP_OBJECT_P (t))
     return dump_expr (pp, DECL_INITIAL (t), flags);
 
   if (flags & TFF_DECL_SPECIFIERS)
diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
index 9925209b2ed..a359bc6ee8d 100644
--- a/gcc/cp/lambda.cc
+++ b/gcc/cp/lambda.cc
@@ -1474,7 +1474,7 @@  void
 start_lambda_scope (tree decl)
 {
   gcc_checking_assert (decl);
-  if (current_function_decl && TREE_CODE (decl) == VAR_DECL)
+  if (current_function_decl && VAR_P (decl))
     // If we're inside a function, we ignore variable scope.  Don't push.
     lambda_scope.nesting++;
   else
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index a235f23459d..826c5e76c1d 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -3793,7 +3793,7 @@  write_template_arg (tree node)
 	}
     }
 
-  if (TREE_CODE (node) == VAR_DECL && DECL_NTTP_OBJECT_P (node))
+  if (VAR_P (node) && DECL_NTTP_OBJECT_P (node))
     /* We want to mangle the argument, not the var we stored it in.  */
     node = tparm_object_argument (node);
 
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index 00eae56eb5b..cbcc7948b37 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -1048,7 +1048,7 @@  spaceship_comp_cat (tree optype)
 {
   if (INTEGRAL_OR_ENUMERATION_TYPE_P (optype) || TYPE_PTROBV_P (optype))
     return cc_strong_ordering;
-  else if (TREE_CODE (optype) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (optype))
     return cc_partial_ordering;
 
   /* ??? should vector <=> produce a vector of one of the above?  */
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index ac2fe66b080..ecde98d69b4 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -4042,7 +4042,7 @@  node_template_info (tree decl, int &use)
 	}
     }
   else if (DECL_LANG_SPECIFIC (decl)
-	   && (TREE_CODE (decl) == VAR_DECL
+	   && (VAR_P (decl)
 	       || TREE_CODE (decl) == TYPE_DECL
 	       || TREE_CODE (decl) == FUNCTION_DECL
 	       || TREE_CODE (decl) == FIELD_DECL
@@ -5151,7 +5151,7 @@  trees_out::start (tree t, bool code_streamed)
   switch (TREE_CODE (t))
     {
     default:
-      if (TREE_CODE_CLASS (TREE_CODE (t)) == tcc_vl_exp)
+      if (VL_EXP_CLASS_P (t))
 	u (VL_EXP_OPERAND_LENGTH (t));
       break;
 
@@ -8551,7 +8551,7 @@  trees_out::decl_node (tree decl, walk_kind ref)
 	{
 	tinfo:
 	  /* A typeinfo, tt_tinfo_typedef or tt_tinfo_var.  */
-	  bool is_var = TREE_CODE (decl) == VAR_DECL;
+	  bool is_var = VAR_P (decl);
 	  tree type = TREE_TYPE (decl);
 	  unsigned ix = get_pseudo_tinfo_index (type);
 	  if (streaming_p ())
@@ -8651,7 +8651,7 @@  trees_out::decl_node (tree decl, walk_kind ref)
      Mostly things that can be defined outside of their (original
      declaration) context.  */
   gcc_checking_assert (TREE_CODE (decl) == TEMPLATE_DECL
-		       || TREE_CODE (decl) == VAR_DECL
+		       || VAR_P (decl)
 		       || TREE_CODE (decl) == FUNCTION_DECL
 		       || TREE_CODE (decl) == TYPE_DECL
 		       || TREE_CODE (decl) == USING_DECL
@@ -11702,7 +11702,7 @@  bool
 trees_in::read_var_def (tree decl, tree maybe_template)
 {
   /* Do not mark the virtual table entries as used.  */
-  bool vtable = TREE_CODE (decl) == VAR_DECL && DECL_VTABLE_OR_VTT_P (decl);
+  bool vtable = VAR_P (decl) && DECL_VTABLE_OR_VTT_P (decl);
   unused += vtable;
   tree init = tree_node ();
   tree dyn_init = init ? NULL_TREE : tree_node ();
@@ -18776,7 +18776,7 @@  void
 set_instantiating_module (tree decl)
 {
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
-	      || TREE_CODE (decl) == VAR_DECL
+	      || VAR_P (decl)
 	      || TREE_CODE (decl) == TYPE_DECL
 	      || TREE_CODE (decl) == CONCEPT_DECL
 	      || TREE_CODE (decl) == TEMPLATE_DECL
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index ad03141df43..eb5c333b5ea 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -3488,7 +3488,7 @@  maybe_record_mergeable_decl (tree *slot, tree name, tree decl)
 
   tree not_tmpl = STRIP_TEMPLATE (decl);
   if ((TREE_CODE (not_tmpl) == FUNCTION_DECL
-       || TREE_CODE (not_tmpl) == VAR_DECL)
+       || VAR_P (not_tmpl))
       && DECL_THIS_STATIC (not_tmpl))
     /* Internal linkage.  */
     return;
@@ -6932,7 +6932,7 @@  consider_decl (tree decl,  best_match <tree, const char *> &bm,
 {
   /* Skip compiler-generated variables (e.g. __for_begin/__for_end
      within range for).  */
-  if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl))
+  if (VAR_P (decl) && DECL_ARTIFICIAL (decl))
     return;
 
   tree suggestion = DECL_NAME (decl);
@@ -6967,7 +6967,7 @@  maybe_add_fuzzy_decl (auto_vec<tree> &vec, tree decl)
 {
   /* Skip compiler-generated variables (e.g. __for_begin/__for_end
      within range for).  */
-  if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl))
+  if (VAR_P (decl) && DECL_ARTIFICIAL (decl))
     return false;
 
   tree suggestion = DECL_NAME (decl);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 696df2bdd9f..16d658e3c6a 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -7487,7 +7487,7 @@  convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
      integral promotions (_conv.prom_) and integral conversions
      (_conv.integral_) are applied.  */
   if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
-      || TREE_CODE (type) == REAL_TYPE)
+      || SCALAR_FLOAT_TYPE_P (type))
     {
       if (cxx_dialect < cxx11)
 	{
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 13c6582b628..05df6282302 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -5169,7 +5169,7 @@  handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
 	  && TREE_CODE (TREE_OPERAND (t, 0)) == COMPONENT_REF)
 	t = TREE_OPERAND (t, 0);
       ret = t;
-      while (TREE_CODE (t) == INDIRECT_REF)
+      while (INDIRECT_REF_P (t))
 	{
 	  t = TREE_OPERAND (t, 0);
 	  STRIP_NOPS (t);
@@ -5206,7 +5206,7 @@  handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
 		}
 	      t = TREE_OPERAND (t, 0);
 	      while (TREE_CODE (t) == MEM_REF
-		     || TREE_CODE (t) == INDIRECT_REF
+		     || INDIRECT_REF_P (t)
 		     || TREE_CODE (t) == ARRAY_REF)
 		{
 		  t = TREE_OPERAND (t, 0);
@@ -8097,7 +8097,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 			  if (REFERENCE_REF_P (t))
 			    t = TREE_OPERAND (t, 0);
 			  if (TREE_CODE (t) == MEM_REF
-			      || TREE_CODE (t) == INDIRECT_REF)
+			      || INDIRECT_REF_P (t))
 			    {
 			      t = TREE_OPERAND (t, 0);
 			      STRIP_NOPS (t);
@@ -8182,7 +8182,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 		  && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH)
 		OMP_CLAUSE_DECL (c) = t;
 	    }
-	  while (TREE_CODE (t) == INDIRECT_REF
+	  while (INDIRECT_REF_P (t)
 		 || TREE_CODE (t) == ARRAY_REF)
 	    {
 	      t = TREE_OPERAND (t, 0);
@@ -8201,7 +8201,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 	    remove = true;
 	  indir_component_ref_p = false;
 	  if (TREE_CODE (t) == COMPONENT_REF
-	      && (TREE_CODE (TREE_OPERAND (t, 0)) == INDIRECT_REF
+	      && (INDIRECT_REF_P (TREE_OPERAND (t, 0))
 		  || TREE_CODE (TREE_OPERAND (t, 0)) == ARRAY_REF))
 	    {
 	      t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
@@ -8255,7 +8255,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 			t = TREE_OPERAND (t, 0);
 		    }
 		  while (TREE_CODE (t) == MEM_REF
-			 || TREE_CODE (t) == INDIRECT_REF
+			 || INDIRECT_REF_P (t)
 			 || TREE_CODE (t) == ARRAY_REF)
 		    {
 		      t = TREE_OPERAND (t, 0);
@@ -8706,7 +8706,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 		  t = OMP_CLAUSE_DECL (c);
 		  while (TREE_CODE (t) == TREE_LIST)
 		    t = TREE_CHAIN (t);
-		  while (TREE_CODE (t) == INDIRECT_REF
+		  while (INDIRECT_REF_P (t)
 			 || TREE_CODE (t) == ARRAY_REF)
 		    t = TREE_OPERAND (t, 0);
 		}
@@ -9021,7 +9021,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 	    {
 	      t = OMP_CLAUSE_DECL (c);
 	      while (handled_component_p (t)
-		     || TREE_CODE (t) == INDIRECT_REF
+		     || INDIRECT_REF_P (t)
 		     || TREE_CODE (t) == ADDR_EXPR
 		     || TREE_CODE (t) == MEM_REF
 		     || TREE_CODE (t) == NON_LVALUE_EXPR)
@@ -9070,7 +9070,7 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 		  if (TREE_CODE (t) == POINTER_PLUS_EXPR)
 		    t = TREE_OPERAND (t, 0);
 		  if (TREE_CODE (t) == ADDR_EXPR
-		      || TREE_CODE (t) == INDIRECT_REF)
+		      || INDIRECT_REF_P (t))
 		    t = TREE_OPERAND (t, 0);
 		  if (DECL_P (t))
 		    bitmap_clear_bit (&aligned_head, DECL_UID (t));
@@ -9609,7 +9609,7 @@  finish_omp_target_clauses_r (tree *tp, int *walk_subtrees, void *ptr)
      of DECL_VALUE_EXPRs during the target body walk seems the only way to
      find them.  */
   if (current_closure
-      && (TREE_CODE (t) == VAR_DECL
+      && (VAR_P (t)
 	  || TREE_CODE (t) == PARM_DECL
 	  || TREE_CODE (t) == RESULT_DECL)
       && DECL_HAS_VALUE_EXPR_P (t)
@@ -12362,8 +12362,8 @@  is_this_parameter (tree t)
   if (!DECL_P (t) || DECL_NAME (t) != this_identifier)
     return false;
   gcc_assert (TREE_CODE (t) == PARM_DECL
-	      || (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
-	      || (cp_binding_oracle && TREE_CODE (t) == VAR_DECL));
+	      || (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
+	      || (cp_binding_oracle && VAR_P (t)));
   return true;
 }
 
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 131b212ff73..19dfb3ed782 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1173,7 +1173,7 @@  build_cplus_array_type (tree elt_type, tree index_type, int dependent)
     }
 
   /* Avoid spurious warnings with VLAs (c++/54583).  */
-  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
+  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
     suppress_warning (TYPE_SIZE (t), OPT_Wunused);
 
   /* Push these needs up to the ARRAY_TYPE so that initialization takes
@@ -3911,7 +3911,7 @@  is_this_expression (tree t)
 {
   t = get_innermost_component (t);
   /* See through deferences and no-op conversions.  */
-  if (TREE_CODE (t) == INDIRECT_REF)
+  if (INDIRECT_REF_P (t))
     t = TREE_OPERAND (t, 0);
   if (TREE_CODE (t) == NOP_EXPR)
     t = TREE_OPERAND (t, 0);
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 53ac925a092..a4ceb8a1703 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -4996,8 +4996,8 @@  do_warn_enum_conversions (location_t loc, enum tree_code code, tree type0,
 	}
     }
   else if ((TREE_CODE (type0) == ENUMERAL_TYPE
-	    && TREE_CODE (type1) == REAL_TYPE)
-	   || (TREE_CODE (type0) == REAL_TYPE
+	    && SCALAR_FLOAT_TYPE_P (type1))
+	   || (SCALAR_FLOAT_TYPE_P (type0)
 	       && TREE_CODE (type1) == ENUMERAL_TYPE))
     {
       const bool enum_first_p = TREE_CODE (type0) == ENUMERAL_TYPE;
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index bf03967a71f..6affdc73fb1 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -907,7 +907,7 @@  store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
      here it should have been digested into an actual value for the type.  */
   gcc_checking_assert (TREE_CODE (value) != CONSTRUCTOR
 		       || processing_template_decl
-		       || TREE_CODE (type) == VECTOR_TYPE
+		       || VECTOR_TYPE_P (type)
 		       || !TREE_HAS_CONSTRUCTOR (value));
 
   /* If the initializer is not a constant, fill in DECL_INITIAL with
@@ -974,7 +974,7 @@  check_narrowing (tree type, tree init, tsubst_flags_t complain,
     return ok;
 
   if (CP_INTEGRAL_TYPE_P (type)
-      && TREE_CODE (ftype) == REAL_TYPE)
+      && SCALAR_FLOAT_TYPE_P (ftype))
     ok = false;
   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
 	   && CP_INTEGRAL_TYPE_P (type))
@@ -992,8 +992,8 @@  check_narrowing (tree type, tree init, tsubst_flags_t complain,
     }
   /* [dcl.init.list]#7.2: "from long double to double or float, or from
       double to float".  */
-  else if (TREE_CODE (ftype) == REAL_TYPE
-	   && TREE_CODE (type) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (ftype)
+	   && SCALAR_FLOAT_TYPE_P (type))
     {
       if ((extended_float_type_p (ftype) || extended_float_type_p (type))
 	  ? /* "from a floating-point type T to another floating-point type
@@ -1030,7 +1030,7 @@  check_narrowing (tree type, tree init, tsubst_flags_t complain,
 	}
     }
   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
-	   && TREE_CODE (type) == REAL_TYPE)
+	   && SCALAR_FLOAT_TYPE_P (type))
     {
       ok = false;
       if (TREE_CODE (init) == INTEGER_CST)