public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ken Matsui <kmatsui@gcc.gnu.org>
To: gcc-patches@gcc.gnu.org
Cc: Ken Matsui <kmatsui@gcc.gnu.org>
Subject: [PATCH 2/8] gcc: Use TYPE_REF_P
Date: Tue, 18 Jul 2023 16:12:44 -0700	[thread overview]
Message-ID: <20230718233301.28677-3-kmatsui@gcc.gnu.org> (raw)
In-Reply-To: <20230718233301.28677-1-kmatsui@gcc.gnu.org>

gcc/ada/ChangeLog:

	* gcc-interface/trans.cc (return_slot_opt_for_pure_call_p): Use TYPE_REF_P.
	* gcc-interface/utils2.cc (build_unary_op): Likewise.

gcc/ChangeLog:

	* alias.cc (get_alias_set): Use TYPE_REF_P.
	* config/gcn/gcn-tree.cc (gcn_goacc_get_worker_red_decl): Likewise.
	* fold-const.cc (fold_unary_loc): Likewise.
	* gimple.cc (gimple_call_nonnull_result_p): Likewise.
	* gimplify.cc (gimplify_decl_expr): Likewise.
	(omp_notice_variable): Likewise.
	(omp_accumulate_sibling_list): Likewise.
	(omp_build_struct_sibling_lists): Likewise.
	(gimplify_scan_omp_clauses): Likewise.
	(omp_shared_to_firstprivate_optimizable_decl_p): Likewise.
	(gimplify_adjust_omp_clauses_1): Likewise.
	(gimplify_omp_taskloop_expr): Likewise.
	* ipa-free-lang-data.cc (find_decls_types_r): Likewise.
	* ipa-sra.cc (create_parameter_descriptors): Likewise.
	* langhooks.cc (lhd_omp_scalar_p): Likewise.
	* match.pd: Likewise.
	* omp-low.cc (scan_sharing_clauses): Likewise.
	(lower_rec_input_clauses): Likewise.
	(create_task_copyfn): Likewise.
	(lower_omp_target): Likewise.
	(lower_omp_1): Likewise.
	* omp-simd-clone.cc (simd_clone_clauses_extract): Likewise.
	(simd_clone_linear_addend): Likewise.
	(simd_clone_adjust): Likewise.
	* tree-inline.cc (remap_type_1): Likewise.
	* tree.cc (reconstruct_complex_type): Likewise.
	(verify_type_variant): Likewise.
	(verify_type): Likewise.
	(nonnull_arg_p): Likewise.
	* tree.h (POINTER_TYPE_P): Likewise.
	* var-tracking.cc (prepare_call_arguments): Likewise.
	(vt_add_function_parameter): Likewise.

gcc/c-family/ChangeLog:

	* c-attribs.cc (has_attribute): Use TYPE_REF_P.
	* c-common.cc (c_common_truthvalue_conversion): Likewise.
	(c_apply_type_quals_to_decl): Likewise.
	* c-pretty-print.cc (c_pretty_printer::unary_expression): Likewise.
	* c-ubsan.cc (ubsan_maybe_instrument_reference_or_call): Likewise.
	* c-warn.cc (warn_if_unused_value): Likewise.

gcc/cp/ChangeLog:

	* constexpr.cc (check_bit_cast_type): Use TYPE_REF_P.
	* coroutines.cc (analyze_fn_parms): Likewise.
	* decl.cc (finish_function): Likewise.
	* init.cc (find_allocator_temps_r): Likewise.
	* method.cc (early_check_defaulted_comparison): Likewise.
	(build_comparison_op): Likewise.
	* pt.cc (value_dependent_expression_p): Likewise.
	* semantics.cc (cp_oacc_check_attachments): Likewise.
	(finish_omp_target_clauses_r): Likewise.
	(finish_omp_target_clauses): Likewise.

gcc/d/ChangeLog:

	* d-builtins.cc (build_frontend_type): Use TYPE_REF_P.
	* d-codegen.cc (indirect_ref): Likewise.
	* d-convert.cc (d_truthvalue_conversion): Likewise.

gcc/fortran/ChangeLog:

	* trans-array.cc (gfc_conv_descriptor_data_get): Use TYPE_REF_P.
	(structure_alloc_comps): Likewise.
	* trans-decl.cc (gfc_generate_function_code): Likewise.
	* trans-expr.cc (gfc_conv_class_to_class): Likewise.
	* trans-intrinsic.cc (gfc_conv_intrinsic_caf_get): Likewise.
	(conv_caf_send): Likewise.
	(trans_caf_is_present): Likewise.
	(conv_intrinsic_atomic_op): Likewise.
	(conv_intrinsic_atomic_ref): Likewise.
	(conv_intrinsic_atomic_cas): Likewise.
	* trans-openmp.cc (gfc_omp_privatize_by_reference): Likewise.
	(gfc_omp_finish_clause): Likewise.
	(gfc_omp_scalar_p): Likewise.
	(gfc_trans_omp_array_reduction_or_udr): Likewise.
	(gfc_trans_omp_clauses): Likewise.

gcc/lto/ChangeLog:

	* lto-common.cc (lto_fixup_prevailing_type): Use TYPE_REF_P.

gcc/m2/ChangeLog:

	* gm2-gcc/m2tree.cc (m2tree_skip_reference_type): Use TYPE_REF_P.
	* gm2-gcc/m2treelib.cc (m2treelib_get_set_value): Likewise.
	* m2pp.cc (m2pp_parameter): Likewise.
	(m2pp_param_type): Likewise.

gcc/objc/ChangeLog:

	* objc-act.cc: Use TYPE_REF_P.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
 gcc/ada/gcc-interface/trans.cc  |  2 +-
 gcc/ada/gcc-interface/utils2.cc |  2 +-
 gcc/alias.cc                    |  2 +-
 gcc/c-family/c-attribs.cc       |  2 +-
 gcc/c-family/c-common.cc        |  7 +++----
 gcc/c-family/c-pretty-print.cc  |  2 +-
 gcc/c-family/c-ubsan.cc         |  4 ++--
 gcc/c-family/c-warn.cc          |  2 +-
 gcc/config/gcn/gcn-tree.cc      |  2 +-
 gcc/cp/constexpr.cc             |  2 +-
 gcc/cp/coroutines.cc            |  2 +-
 gcc/cp/decl.cc                  |  2 +-
 gcc/cp/init.cc                  |  2 +-
 gcc/cp/method.cc                |  4 ++--
 gcc/cp/pt.cc                    |  2 +-
 gcc/cp/semantics.cc             | 10 +++++-----
 gcc/d/d-builtins.cc             |  2 +-
 gcc/d/d-codegen.cc              |  2 +-
 gcc/d/d-convert.cc              |  4 ++--
 gcc/fold-const.cc               |  2 +-
 gcc/fortran/trans-array.cc      |  4 ++--
 gcc/fortran/trans-decl.cc       |  2 +-
 gcc/fortran/trans-expr.cc       |  2 +-
 gcc/fortran/trans-intrinsic.cc  | 16 ++++++++--------
 gcc/fortran/trans-openmp.cc     | 10 +++++-----
 gcc/gimple.cc                   |  2 +-
 gcc/gimplify.cc                 | 18 +++++++++---------
 gcc/ipa-free-lang-data.cc       |  2 +-
 gcc/ipa-sra.cc                  |  2 +-
 gcc/langhooks.cc                |  2 +-
 gcc/lto/lto-common.cc           |  2 +-
 gcc/m2/gm2-gcc/m2tree.cc        |  2 +-
 gcc/m2/gm2-gcc/m2treelib.cc     |  2 +-
 gcc/m2/m2pp.cc                  |  4 ++--
 gcc/match.pd                    |  2 +-
 gcc/objc/objc-act.cc            |  2 +-
 gcc/omp-low.cc                  | 17 ++++++++---------
 gcc/omp-simd-clone.cc           |  8 ++++----
 gcc/tree-inline.cc              |  2 +-
 gcc/tree.cc                     | 10 +++++-----
 gcc/tree.h                      |  2 +-
 gcc/var-tracking.cc             |  6 +++---
 42 files changed, 88 insertions(+), 90 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index f5eadbbc895..203d63b2e5e 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -4540,7 +4540,7 @@ return_slot_opt_for_pure_call_p (tree target, tree call)
   FOR_EACH_CALL_EXPR_ARG (arg, iter, call)
     {
       tree arg_type = TREE_TYPE (arg);
-      if (TREE_CODE (arg_type) == REFERENCE_TYPE)
+      if (TYPE_REF_P (arg_type))
 	arg_type = TREE_TYPE (arg_type);
 
       if (is_array_of_scalar_type (arg_type))
diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
index 95bbce2f1b4..022bbf97e8e 100644
--- a/gcc/ada/gcc-interface/utils2.cc
+++ b/gcc/ada/gcc-interface/utils2.cc
@@ -1406,7 +1406,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
 		  = build_pointer_type_for_mode (TREE_TYPE (result_type),
 						 TYPE_MODE (result_type),
 						 true);
-	      else if (TREE_CODE (result_type) == REFERENCE_TYPE
+	      else if (TYPE_REF_P (result_type)
 		       && !TYPE_REF_CAN_ALIAS_ALL (result_type))
 	        result_type
 		  = build_reference_type_for_mode (TREE_TYPE (result_type),
diff --git a/gcc/alias.cc b/gcc/alias.cc
index 7c1af1fe96e..3f2e74b00a4 100644
--- a/gcc/alias.cc
+++ b/gcc/alias.cc
@@ -1041,7 +1041,7 @@ get_alias_set (tree t)
 	      p = ptr_type_node;
 	      break;
 	    }
-	  if (TREE_CODE (p) == REFERENCE_TYPE)
+	  if (TYPE_REF_P (p))
 	    /* In LTO we want languages that use references to be compatible
  	       with languages that use pointers.  */
 	    reference.safe_push (true && !in_lto_p);
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index e2792ca6898..852fd2503ec 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -6098,7 +6098,7 @@ has_attribute (location_t atloc, tree t, tree attr, tree (*convert)(tree))
 	  if (code == INDIRECT_REF)
 	    {
 	      tree op0 = TREE_OPERAND (t, 0);
-	      if (TREE_CODE (TREE_TYPE (op0)) == REFERENCE_TYPE)
+	      if (TYPE_REF_P (TREE_TYPE (op0)))
 		t = op0;
 	      else
 		break;
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 6ab63dae997..6add84c9504 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -3657,7 +3657,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
 
 	if (POINTER_TYPE_P (totype)
 	    && !c_inhibit_evaluation_warnings
-	    && TREE_CODE (fromtype) == REFERENCE_TYPE)
+	    && TYPE_REF_P (fromtype))
 	  {
 	    tree inner = expr;
 	    STRIP_NOPS (inner);
@@ -3672,8 +3672,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
 
 	/* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
 	   since that affects how `default_conversion' will behave.  */
-	if (TREE_CODE (totype) == REFERENCE_TYPE
-	    || TREE_CODE (fromtype) == REFERENCE_TYPE)
+	if (TYPE_REF_P (totype) || TYPE_REF_P (fromtype))
 	  break;
 	/* Don't strip a conversion from C++0x scoped enum, since they
 	   don't implicitly convert to other types.  */
@@ -3768,7 +3767,7 @@ c_apply_type_quals_to_decl (int type_quals, tree decl)
     return;
 
   if ((type_quals & TYPE_QUAL_CONST)
-      || (type && TREE_CODE (type) == REFERENCE_TYPE))
+      || (type && TYPE_REF_P (type)))
     /* We used to check TYPE_NEEDS_CONSTRUCTING here, but now a constexpr
        constructor can produce constant init, so rely on cp_finish_decl to
        clear TREE_READONLY if the variable has non-constant init.  */
diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index 7536a7c471f..63a77231500 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -2181,7 +2181,7 @@ c_pretty_printer::unary_expression (tree e)
       else if (code == INDIRECT_REF)
 	{
 	  tree type = TREE_TYPE (TREE_OPERAND (e, 0));
-	  if (type && TREE_CODE (type) == REFERENCE_TYPE)
+	  if (type && TYPE_REF_P (type))
 	    /* Reference decay is implicit, don't print anything.  */;
 	  else
 	    pp_c_star (this);
diff --git a/gcc/c-family/c-ubsan.cc b/gcc/c-family/c-ubsan.cc
index 51aa83a378d..355dc67aa61 100644
--- a/gcc/c-family/c-ubsan.cc
+++ b/gcc/c-family/c-ubsan.cc
@@ -534,7 +534,7 @@ ubsan_maybe_instrument_reference_or_call (location_t loc, tree op, tree ptype,
 	 && TREE_CODE (TREE_TYPE (op)) == POINTER_TYPE)
     op = TREE_OPERAND (op, 0);
   if (TREE_CODE (op) == NOP_EXPR
-      && TREE_CODE (TREE_TYPE (op)) == REFERENCE_TYPE)
+      && TYPE_REF_P (TREE_TYPE (op)))
     {
       if (mina && mina > min_align_of_type (TREE_TYPE (TREE_TYPE (op))))
 	instrument = true;
@@ -570,7 +570,7 @@ ubsan_maybe_instrument_reference_or_call (location_t loc, tree op, tree ptype,
     return NULL_TREE;
   op = save_expr (orig_op);
   gcc_assert (POINTER_TYPE_P (ptype));
-  if (TREE_CODE (ptype) == REFERENCE_TYPE)
+  if (TYPE_REF_P (ptype))
     ptype = build_pointer_type (TREE_TYPE (ptype));
   tree kind = build_int_cst (ptype, ckind);
   tree align = build_int_cst (pointer_sized_int_node, mina);
diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc
index d4d62c48b20..b92b4f9ecb1 100644
--- a/gcc/c-family/c-warn.cc
+++ b/gcc/c-family/c-warn.cc
@@ -659,7 +659,7 @@ warn_if_unused_value (const_tree exp, location_t locus, bool quiet)
     case INDIRECT_REF:
       /* Don't warn about automatic dereferencing of references, since
 	 the user cannot control it.  */
-      if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (TREE_OPERAND (exp, 0))))
 	{
 	  exp = TREE_OPERAND (exp, 0);
 	  goto restart;
diff --git a/gcc/config/gcn/gcn-tree.cc b/gcc/config/gcn/gcn-tree.cc
index c99c1767659..eed16bcfd27 100644
--- a/gcc/config/gcn/gcn-tree.cc
+++ b/gcc/config/gcn/gcn-tree.cc
@@ -310,7 +310,7 @@ gcn_goacc_get_worker_red_decl (tree type, unsigned offset)
 {
   machine_function *machfun = cfun->machine;
 
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+  if (TYPE_REF_P (type))
     type = TREE_TYPE (type);
 
   tree var_type
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 9d85c3be5cc..8c416d7bdfc 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -4544,7 +4544,7 @@ check_bit_cast_type (const constexpr_ctx *ctx, location_t loc, tree type,
 	}
       return true;
     }
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+  if (TYPE_REF_P (type))
     {
       if (!ctx->quiet)
 	{
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 3493d3c6ed3..a6e04dc0f10 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3834,7 +3834,7 @@ analyze_fn_parms (tree orig)
 	actual_type = error_mark_node;
       parm.orig_type = actual_type;
       parm.by_ref = parm.pt_ref = parm.rv_ref =  false;
-      if (TREE_CODE (actual_type) == REFERENCE_TYPE)
+      if (TYPE_REF_P (actual_type))
 	{
 	  /* If the user passes by reference, then we will save the
 	     pointer to the original.  As noted in
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 792ab330dd0..c08056ca3d2 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -18210,7 +18210,7 @@ finish_function (bool inline_p)
       if (IDENTIFIER_ASSIGN_OP_P (DECL_NAME (fndecl)))
 	{
 	  tree valtype = TREE_TYPE (DECL_RESULT (fndecl));
-	  if (TREE_CODE (valtype) == REFERENCE_TYPE
+	  if (TYPE_REF_P (valtype)
 	      && current_class_ref
 	      && same_type_ignoring_top_level_qualifiers_p
 		  (TREE_TYPE (valtype), TREE_TYPE (current_class_ref))
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index ff5014ca576..01eb4b55889 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4366,7 +4366,7 @@ find_allocator_temps_r (tree *tp, int *walk_subtrees, void *data)
 	{
 	  tree arg = get_nth_callarg (t, i);
 	  tree atype = TREE_TYPE (arg);
-	  if (TREE_CODE (atype) == REFERENCE_TYPE
+	  if (TYPE_REF_P (atype)
 	      && is_std_allocator (TREE_TYPE (atype)))
 	    {
 	      STRIP_NOPS (arg);
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index 8ed967ddb21..524efc4e260 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -1207,7 +1207,7 @@ early_check_defaulted_comparison (tree fn)
       tree parmtype = TREE_VALUE (parmnode);
       if (CLASS_TYPE_P (parmtype))
 	saw_byval = true;
-      else if (TREE_CODE (parmtype) == REFERENCE_TYPE
+      else if (TYPE_REF_P (parmtype)
 	       && !TYPE_REF_IS_RVALUE (parmtype)
 	       && TYPE_QUALS (TREE_TYPE (parmtype)) == TYPE_QUAL_CONST)
 	{
@@ -1533,7 +1533,7 @@ build_comparison_op (tree fndecl, bool defining, tsubst_flags_t complain)
 	  /* A defaulted comparison operator function for class C is defined as
 	     deleted if any non-static data member of C is of reference type or
 	     C has variant members.  */
-	  if (TREE_CODE (expr_type) == REFERENCE_TYPE)
+	  if (TYPE_REF_P (expr_type))
 	    {
 	      if (complain & tf_error)
 		inform (field_loc, "cannot default compare "
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 255d18b9539..cb82e1b268b 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -28023,7 +28023,7 @@ value_dependent_expression_p (tree expression)
 	if (TREE_CODE (expression) == TREE_LIST)
 	  return any_value_dependent_elements_p (expression);
 
-	if (TREE_CODE (type) == REFERENCE_TYPE
+	if (TYPE_REF_P (type)
 	    && has_value_dependent_address (expression))
 	  return true;
 
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 8fb47fd179e..8f4b2532934 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -6816,7 +6816,7 @@ cp_oacc_check_attachments (tree c)
 
       type = TREE_TYPE (t);
 
-      if (TREE_CODE (type) == REFERENCE_TYPE)
+      if (TYPE_REF_P (type))
 	type = TREE_TYPE (type);
 
       if (TREE_CODE (type) != POINTER_TYPE)
@@ -9645,7 +9645,7 @@ finish_omp_target_clauses_r (tree *tp, int *walk_subtrees, void *ptr)
 	  tree fld = TREE_OPERAND (t, 1);
 	  if (data->ptr_members_accessed.get (fld) == NULL)
 	    {
-	      if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
+	      if (TYPE_REF_P (TREE_TYPE (t)))
 		t = convert_from_reference (t);
 	      data->ptr_members_accessed.put (fld, t);
 	    }
@@ -9834,7 +9834,7 @@ finish_omp_target_clauses (location_t loc, tree body, tree *clauses_ptr)
 	  tree closure_expr = DECL_VALUE_EXPR (orig_decl);
 
 	  if (TREE_CODE (TREE_TYPE (orig_decl)) == POINTER_TYPE
-	      || TREE_CODE (TREE_TYPE (orig_decl)) == REFERENCE_TYPE)
+	      || TYPE_REF_P (TREE_TYPE (orig_decl)))
 	    {
 	      /* this-pointer is processed above, outside this loop.  */
 	      if (omp_target_this_expr
@@ -9931,7 +9931,7 @@ finish_omp_target_clauses (location_t loc, tree body, tree *clauses_ptr)
 	if (!cxx_mark_addressable (ptr_member))
 	  gcc_unreachable ();
 
-	if (TREE_CODE (TREE_TYPE (field_decl)) == REFERENCE_TYPE)
+	if (TYPE_REF_P (TREE_TYPE (field_decl)))
 	  {
 	    /* For reference to pointers, we need to map the referenced
 	       pointer first for things to be correct.  */
@@ -10026,7 +10026,7 @@ finish_omp_target_clauses (location_t loc, tree body, tree *clauses_ptr)
 	      OMP_CLAUSE_SIZE (c) = size_zero_node;
 	      new_clauses.safe_push (c);
 	    }
-	  else if (TREE_CODE (TREE_TYPE (fld)) == REFERENCE_TYPE)
+	  else if (TYPE_REF_P (TREE_TYPE (fld)))
 	    {
 	      tree exp = build3 (COMPONENT_REF, TREE_TYPE (fld),
 				 lobj, fld, NULL_TREE);
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 60f76fc694c..bfd455613de 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -307,7 +307,7 @@ build_frontend_type (tree type)
 		}
 
 	      StorageClass sc = STCundefined;
-	      if (TREE_CODE (argtype) == REFERENCE_TYPE)
+	      if (TYPE_REF_P (argtype))
 		{
 		  argtype = TREE_TYPE (argtype);
 		  sc |= STCref;
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 2738958fde1..ab48b55ada7 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1625,7 +1625,7 @@ indirect_ref (tree type, tree exp)
   /* Maybe rewrite: *(e1, e2) => (e1, *e2)  */
   tree init = stabilize_expr (&exp);
 
-  if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE)
+  if (TYPE_REF_P (TREE_TYPE (exp)))
     exp = fold_build1 (INDIRECT_REF, type, exp);
   else
     {
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 2b9d8e78fb6..ec75eccbbaf 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -185,8 +185,8 @@ d_truthvalue_conversion (tree expr)
     case CONVERT_EXPR:
       /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
 	 since that affects how `default_conversion' will behave.  */
-      if (TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE
-	  || TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (expr))
+	  || TYPE_REF_P (TREE_TYPE (TREE_OPERAND (expr, 0))))
 	break;
       /* Fall through.  */
 
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index a02ede79fed..15a4e120201 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -9507,7 +9507,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
 	     when type is a reference type and arg00's type is not,
 	     because arg00 could be validly nullptr and if arg01 doesn't return,
 	     we don't want false positive binding of reference to nullptr.  */
-	  if (TREE_CODE (type) == REFERENCE_TYPE
+	  if (TYPE_REF_P (type)
 	      && !in_gimple_form
 	      && sanitize_flags_p (SANITIZE_NULL)
 	      && TREE_CODE (TREE_TYPE (arg00)) != REFERENCE_TYPE)
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 951cecfa5d5..94d8e57750a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -258,7 +258,7 @@ tree
 gfc_conv_descriptor_data_get (tree desc)
 {
   tree type = TREE_TYPE (desc);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+  if (TYPE_REF_P (type))
     gcc_unreachable ();
 
   tree field = gfc_get_descriptor_field (desc, DATA_FIELD);
@@ -9105,7 +9105,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, tree dest,
   decl_type = TREE_TYPE (decl);
 
   if ((POINTER_TYPE_P (decl_type))
-	|| (TREE_CODE (decl_type) == REFERENCE_TYPE && rank == 0))
+	|| (TYPE_REF_P (decl_type) && rank == 0))
     {
       decl = build_fold_indirect_ref_loc (input_location, decl);
       /* Deref dest in sync with decl, but only when it is not NULL.  */
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index b0fd25e92a3..a141fbdeed3 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -7648,7 +7648,7 @@ gfc_generate_function_code (gfc_namespace * ns)
 	if (POINTER_TYPE_P (TREE_TYPE (type)))
 	  /* For instance, allocatable scalars.  */
 	  type = TREE_TYPE (type);
-	if (TREE_CODE (type) == REFERENCE_TYPE)
+	if (TYPE_REF_P (type))
 	  type = build_pointer_type (TREE_TYPE (type));
 	desc_p = build_decl (loc, VAR_DECL, get_identifier (fsym->name), type);
 	if (!fsym->attr.dimension)
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index ef3e6d08f78..b019cda1813 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -1298,7 +1298,7 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts,
   gcc_assert (tmp != NULL_TREE);
 
   /* Dereference if needs be.  */
-  if (TREE_CODE (TREE_TYPE (tmp)) == REFERENCE_TYPE)
+  if (TYPE_REF_P (TREE_TYPE (tmp)))
     tmp = build_fold_indirect_ref_loc (input_location, tmp);
 
   if (!(gfc_is_class_array_function (e) && parmse->class_vptr))
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index b6ea26e413d..87ff0a15237 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -1777,7 +1777,7 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind,
 	    lhs_kind = kind;
 
 	  caf_decl = gfc_get_tree_for_caf_expr (array_expr);
-	  if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+	  if (TYPE_REF_P (TREE_TYPE (caf_decl)))
 	    caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
 	  image_index = gfc_caf_get_image_index (&se->pre, array_expr,
 						 caf_decl);
@@ -1899,7 +1899,7 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind,
   gfc_add_block_to_block (&se->post, &argse.post);
 
   caf_decl = gfc_get_tree_for_caf_expr (array_expr);
-  if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+  if (TYPE_REF_P (TREE_TYPE (caf_decl)))
     caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
   image_index = gfc_caf_get_image_index (&se->pre, array_expr, caf_decl);
   gfc_get_caf_token_offset (se, &token, &offset, caf_decl, argse.expr,
@@ -2166,7 +2166,7 @@ conv_caf_send (gfc_code *code) {
 
   /* Obtain token, offset and image index for the LHS.  */
   caf_decl = gfc_get_tree_for_caf_expr (lhs_expr);
-  if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+  if (TYPE_REF_P (TREE_TYPE (caf_decl)))
     caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
   image_index = gfc_caf_get_image_index (&block, lhs_expr, caf_decl);
   tmp = lhs_se.expr;
@@ -2305,7 +2305,7 @@ conv_caf_send (gfc_code *code) {
       gfc_add_expr_to_block (&block, tmp);
 
       caf_decl = gfc_get_tree_for_caf_expr (rhs_expr);
-      if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (caf_decl)))
 	caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
       rhs_image_index = gfc_caf_get_image_index (&block, rhs_expr, caf_decl);
       tmp = rhs_se.expr;
@@ -8783,7 +8783,7 @@ trans_caf_is_present (gfc_se *se, gfc_expr *expr)
   gcc_assert (caf_reference != NULL_TREE);
 
   caf_decl = gfc_get_tree_for_caf_expr (expr);
-  if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+  if (TYPE_REF_P (TREE_TYPE (caf_decl)))
     caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
   image_index = gfc_caf_get_image_index (&se->pre, expr, caf_decl);
   gfc_get_caf_token_offset (se, &token, NULL, caf_decl, NULL,
@@ -11845,7 +11845,7 @@ conv_intrinsic_atomic_op (gfc_code *code)
 	}
 
       caf_decl = gfc_get_tree_for_caf_expr (atom_expr);
-      if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (caf_decl)))
 	caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
 
       if (gfc_is_coindexed (atom_expr))
@@ -12001,7 +12001,7 @@ conv_intrinsic_atomic_ref (gfc_code *code)
       tree orig_value = NULL_TREE, vardecl = NULL_TREE;
 
       caf_decl = gfc_get_tree_for_caf_expr (atom_expr);
-      if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (caf_decl)))
 	caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
 
       if (gfc_is_coindexed (atom_expr))
@@ -12123,7 +12123,7 @@ conv_intrinsic_atomic_cas (gfc_code *code)
       tree image_index, caf_decl, offset, token;
 
       caf_decl = gfc_get_tree_for_caf_expr (atom_expr);
-      if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (caf_decl)))
 	caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
 
       if (gfc_is_coindexed (atom_expr))
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index c88ee3c7656..a676442ca9e 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -219,7 +219,7 @@ gfc_omp_privatize_by_reference (const_tree decl)
 {
   tree type = TREE_TYPE (decl);
 
-  if (TREE_CODE (type) == REFERENCE_TYPE
+  if (TYPE_REF_P (type)
       && (!DECL_ARTIFICIAL (decl) || TREE_CODE (decl) == PARM_DECL))
     return true;
 
@@ -1584,7 +1584,7 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
 	  OMP_CLAUSE_DECL (c) = decl;
 	  OMP_CLAUSE_SIZE (c) = NULL_TREE;
 	}
-      if (TREE_CODE (TREE_TYPE (orig_decl)) == REFERENCE_TYPE
+      if (TYPE_REF_P (TREE_TYPE (orig_decl))
 	  && (GFC_DECL_GET_SCALAR_POINTER (orig_decl)
 	      || GFC_DECL_GET_SCALAR_ALLOCATABLE (orig_decl)))
 	{
@@ -1747,7 +1747,7 @@ bool
 gfc_omp_scalar_p (tree decl, bool ptr_alloc_ok)
 {
   tree type = TREE_TYPE (decl);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+  if (TYPE_REF_P (type))
     type = TREE_TYPE (type);
   if (TREE_CODE (type) == POINTER_TYPE)
     {
@@ -2015,7 +2015,7 @@ gfc_trans_omp_array_reduction_or_udr (tree c, gfc_omp_namelist *n, locus where)
   type = TREE_TYPE (decl);
   outer_decl = create_tmp_var_raw (type);
   if (TREE_CODE (decl) == PARM_DECL
-      && TREE_CODE (type) == REFERENCE_TYPE
+      && TYPE_REF_P (type)
       && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (type))
       && GFC_TYPE_ARRAY_AKIND (TREE_TYPE (type)) == GFC_ARRAY_ALLOCATABLE)
     {
@@ -3277,7 +3277,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 			  OMP_CLAUSE_SIZE (node4) = size;
 			}
 		      decl = build_fold_indirect_ref (decl);
-		      if ((TREE_CODE (TREE_TYPE (orig_decl)) == REFERENCE_TYPE
+		      if ((TYPE_REF_P (TREE_TYPE (orig_decl))
 			   || gfc_omp_is_optional_argument (orig_decl))
 			  && (GFC_DECL_GET_SCALAR_POINTER (orig_decl)
 			      || GFC_DECL_GET_SCALAR_ALLOCATABLE (orig_decl)))
diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index e0ba42add39..1c1ff796465 100644
--- a/gcc/gimple.cc
+++ b/gcc/gimple.cc
@@ -1706,7 +1706,7 @@ gimple_call_nonnull_result_p (gcall *call)
 
   /* References are always non-NULL.  */
   if (flag_delete_null_pointer_checks
-      && TREE_CODE (TREE_TYPE (fndecl)) == REFERENCE_TYPE)
+      && TYPE_REF_P (TREE_TYPE (fndecl)))
     return true;
 
   if (flag_delete_null_pointer_checks
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 36e5df050b9..b3ff91b3bd2 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -1861,7 +1861,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
       && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (decl)))
     {
       gimplify_type_sizes (TREE_TYPE (decl), seq_p);
-      if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
+      if (TYPE_REF_P (TREE_TYPE (decl)))
 	gimplify_type_sizes (TREE_TYPE (TREE_TYPE (decl)), seq_p);
     }
 
@@ -1872,7 +1872,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
       && !TYPE_SIZES_GIMPLIFIED (DECL_ORIGINAL_TYPE (decl)))
     {
       gimplify_type_sizes (DECL_ORIGINAL_TYPE (decl), seq_p);
-      if (TREE_CODE (DECL_ORIGINAL_TYPE (decl)) == REFERENCE_TYPE)
+      if (TYPE_REF_P (DECL_ORIGINAL_TYPE (decl)))
 	gimplify_type_sizes (TREE_TYPE (DECL_ORIGINAL_TYPE (decl)), seq_p);
     }
 
@@ -7905,7 +7905,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 		  else if (lang_hooks.decls.omp_scalar_p (decl, false))
 		    gdmk = GDMK_SCALAR;
 		  else if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
-			   || (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+			   || (TYPE_REF_P (TREE_TYPE (decl))
 			       && (TREE_CODE (TREE_TYPE (TREE_TYPE (decl)))
 				   == POINTER_TYPE)))
 		    gdmk = GDMK_POINTER;
@@ -10418,7 +10418,7 @@ omp_accumulate_sibling_list (enum omp_region_type region_type,
 				    ptrdiff_type_node, baddr);
 	  /* This isn't going to be good enough when we add support for more
 	     complicated lvalue expressions.  FIXME.  */
-	  if (TREE_CODE (TREE_TYPE (sdecl)) == REFERENCE_TYPE
+	  if (TYPE_REF_P (TREE_TYPE (sdecl))
 	      && TREE_CODE (TREE_TYPE (TREE_TYPE (sdecl))) == POINTER_TYPE)
 	    sdecl = build_simple_mem_ref (sdecl);
 	  tree decladdr = fold_convert_loc (OMP_CLAUSE_LOCATION (grp_end),
@@ -10677,7 +10677,7 @@ omp_build_struct_sibling_lists (enum tree_code code,
 	    }
 
 	  tree stype = TREE_TYPE (decl);
-	  if (TREE_CODE (stype) == REFERENCE_TYPE)
+	  if (TYPE_REF_P (stype))
 	    stype = TREE_TYPE (stype);
 	  if (TYPE_SIZE_UNIT (stype) == NULL
 	      || TREE_CODE (TYPE_SIZE_UNIT (stype)) != INTEGER_CST)
@@ -11801,7 +11801,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
 		  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
 		      && TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF
 		      && (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
-			  || (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+			  || (TYPE_REF_P (TREE_TYPE (decl))
 			      && (TREE_CODE (TREE_TYPE (TREE_TYPE (decl)))
 				  == POINTER_TYPE))))
 		    omp_firstprivatize_variable (outer_ctx, decl);
@@ -12184,7 +12184,7 @@ omp_shared_to_firstprivate_optimizable_decl_p (tree decl)
     return false;
   tree type = TREE_TYPE (decl);
   if (!is_gimple_reg_type (type)
-      || TREE_CODE (type) == REFERENCE_TYPE
+      || TYPE_REF_P (type)
       || TREE_ADDRESSABLE (type))
     return false;
   /* Don't optimize too large decls, as each thread/task will have
@@ -12432,7 +12432,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
     {
       tree nc = build_omp_clause (input_location, OMP_CLAUSE_MAP);
       OMP_CLAUSE_DECL (nc) = decl;
-      if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+      if (TYPE_REF_P (TREE_TYPE (decl))
 	  && TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == POINTER_TYPE)
 	OMP_CLAUSE_DECL (clause)
 	  = build_simple_mem_ref_loc (input_location, decl);
@@ -13591,7 +13591,7 @@ gimplify_omp_taskloop_expr (tree type, tree *tp, gimple_seq *pre_p,
      here.  */
   if (type
       && TREE_CODE (type) == POINTER_TYPE
-      && TREE_CODE (TREE_TYPE (*tp)) == REFERENCE_TYPE)
+      && TYPE_REF_P (TREE_TYPE (*tp)))
     {
       tree v = create_tmp_var (TYPE_MAIN_VARIANT (type));
       tree m = build2 (INIT_EXPR, TREE_TYPE (v), v, *tp);
diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index ff9657a6e06..1a2417e8592 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -771,7 +771,7 @@ find_decls_types_r (tree *tp, int *ws, void *data)
 	 in them.  */
       if (TREE_CODE (t) == POINTER_TYPE)
 	fld_worklist_push (TYPE_NEXT_PTR_TO (t), fld);
-      if (TREE_CODE (t) == REFERENCE_TYPE)
+      if (TYPE_REF_P (t))
 	fld_worklist_push (TYPE_NEXT_REF_TO (t), fld);
       if (!POINTER_TYPE_P (t))
 	fld_worklist_push (TYPE_MIN_VALUE_RAW (t), fld);
diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc
index c35e03b7abd..e203d8941ff 100644
--- a/gcc/ipa-sra.cc
+++ b/gcc/ipa-sra.cc
@@ -1206,7 +1206,7 @@ create_parameter_descriptors (cgraph_node *node,
       if (POINTER_TYPE_P (type))
 	{
 	  desc->by_ref = true;
-	  if (TREE_CODE (type) == REFERENCE_TYPE
+	  if (TYPE_REF_P (type)
 	      || (num == 0
 		  && TREE_CODE (TREE_TYPE (node->decl)) == METHOD_TYPE))
 	    desc->safe_ref = true;
diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc
index 9a1a9eccca9..e3030286ecc 100644
--- a/gcc/langhooks.cc
+++ b/gcc/langhooks.cc
@@ -650,7 +650,7 @@ bool
 lhd_omp_scalar_p (tree decl, bool ptr_ok)
 {
   tree type = TREE_TYPE (decl);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+  if (TYPE_REF_P (type))
     type = TREE_TYPE (type);
   if (TREE_CODE (type) == COMPLEX_TYPE)
     type = TREE_TYPE (type);
diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 703e665b698..207a5d4f926 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -998,7 +998,7 @@ lto_fixup_prevailing_type (tree t)
 	  TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (TREE_TYPE (t));
 	  TYPE_POINTER_TO (TREE_TYPE (t)) = t;
 	}
-      else if (TREE_CODE (t) == REFERENCE_TYPE && !TYPE_REF_IS_RVALUE (t))
+      else if (TYPE_REF_P (t) && !TYPE_REF_IS_RVALUE (t))
 	{
 	  TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (TREE_TYPE (t));
 	  TYPE_REFERENCE_TO (TREE_TYPE (t)) = t;
diff --git a/gcc/m2/gm2-gcc/m2tree.cc b/gcc/m2/gm2-gcc/m2tree.cc
index 99405123290..2c87945ec06 100644
--- a/gcc/m2/gm2-gcc/m2tree.cc
+++ b/gcc/m2/gm2-gcc/m2tree.cc
@@ -95,7 +95,7 @@ m2tree_skip_const_decl (tree exp)
 tree
 m2tree_skip_reference_type (tree exp)
 {
-  if (TREE_CODE (exp) == REFERENCE_TYPE)
+  if (TYPE_REF_P (exp))
     return m2tree_skip_reference_type (TREE_TYPE (exp));
   if (TREE_CODE (exp) == POINTER_TYPE)
     return m2tree_skip_reference_type (TREE_TYPE (exp));
diff --git a/gcc/m2/gm2-gcc/m2treelib.cc b/gcc/m2/gm2-gcc/m2treelib.cc
index 6694af66d8b..56231701f7a 100644
--- a/gcc/m2/gm2-gcc/m2treelib.cc
+++ b/gcc/m2/gm2-gcc/m2treelib.cc
@@ -302,7 +302,7 @@ m2treelib_get_set_value (location_t location, tree p, tree field, bool is_const,
             field);
       else
         {
-          ASSERT_CONDITION (TREE_CODE (TREE_TYPE (p)) == REFERENCE_TYPE);
+          ASSERT_CONDITION (TYPE_REF_P (TREE_TYPE (p)));
           value = m2expr_BuildComponentRef (location, p, field);
         }
     }
diff --git a/gcc/m2/m2pp.cc b/gcc/m2/m2pp.cc
index 52a29384e8d..d87995affe7 100644
--- a/gcc/m2/m2pp.cc
+++ b/gcc/m2/m2pp.cc
@@ -905,7 +905,7 @@ m2pp_parameter (pretty *s, tree t)
 {
   if (TREE_CODE (t) == PARM_DECL)
     {
-      if (TREE_TYPE (t) && (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
+      if (TREE_TYPE (t) && TYPE_REF_P (TREE_TYPE (t)))
         {
           m2pp_print (s, "VAR");
           m2pp_needspace (s);
@@ -929,7 +929,7 @@ m2pp_parameter (pretty *s, tree t)
 static void
 m2pp_param_type (pretty *s, tree t)
 {
-  if (t && (TREE_CODE (t) == REFERENCE_TYPE))
+  if (t && TYPE_REF_P (t))
     {
       m2pp_print (s, "VAR");
       m2pp_needspace (s);
diff --git a/gcc/match.pd b/gcc/match.pd
index 054e6585876..5f7627c8d5e 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6343,7 +6343,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 	 /* Don't perform this optimization in GENERIC if @0 has reference
 	    type when sanitizing.  See PR101210.  */
 	 && !(GENERIC
-	      && TREE_CODE (TREE_TYPE (@0)) == REFERENCE_TYPE
+	      && TYPE_REF_P (TREE_TYPE (@0))
 	      && (flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT))))
 	|| (INTEGRAL_TYPE_P (TREE_TYPE (@0))
 	    && POINTER_TYPE_P (TREE_TYPE (@1))
diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc
index e4c49e664e1..528a4ae812a 100644
--- a/gcc/objc/objc-act.cc
+++ b/gcc/objc/objc-act.cc
@@ -6374,7 +6374,7 @@ add_instance_variable (tree klass, objc_ivar_visibility_kind visibility,
   tree field_type = TREE_TYPE (field_decl);
 
 #ifdef OBJCPLUS
-  if (TREE_CODE (field_type) == REFERENCE_TYPE)
+  if (TYPE_REF_P (field_type))
     {
       error ("illegal reference type specified for instance variable %qs",
 	     printable_ivar_name (field_decl));
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index b882df048ef..5dd9b77c873 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -1298,7 +1298,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 		  && (!is_global_var (maybe_lookup_decl_in_outer_ctx (t, ctx))
 		      || (is_task_ctx (ctx)
 			  && (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE
-			      || (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
+			      || (TYPE_REF_P (TREE_TYPE (t))
 				  && (TREE_CODE (TREE_TYPE (TREE_TYPE (t)))
 				      == POINTER_TYPE)))))
 		  && !is_variable_sized (t)
@@ -1308,7 +1308,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 		{
 		  by_ref = use_pointer_for_field (t, NULL);
 		  if (is_task_ctx (ctx)
-		      && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
+		      && TYPE_REF_P (TREE_TYPE (t))
 		      && TREE_CODE (TREE_TYPE (TREE_TYPE (t))) == POINTER_TYPE)
 		    {
 		      install_var_field (t, false, 1, ctx);
@@ -5306,7 +5306,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
 		    {
 		      bool by_ref = use_pointer_for_field (var, NULL);
 		      x = build_receiver_ref (var, by_ref, ctx);
-		      if (TREE_CODE (TREE_TYPE (var)) == REFERENCE_TYPE
+		      if (TYPE_REF_P (TREE_TYPE (var))
 			  && (TREE_CODE (TREE_TYPE (TREE_TYPE (var)))
 			      == POINTER_TYPE))
 			x = build_fold_addr_expr (x);
@@ -12200,7 +12200,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx)
 	src = build_simple_mem_ref_loc (loc, sarg);
 	src = omp_build_component_ref (src, sf);
 	if (decl != OMP_CLAUSE_DECL (c)
-	    && TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+	    && TYPE_REF_P (TREE_TYPE (decl))
 	    && TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == POINTER_TYPE)
 	  src = build_simple_mem_ref_loc (loc, src);
 	dst = build_simple_mem_ref_loc (loc, arg);
@@ -13313,7 +13313,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 	      {
 		gcc_checking_assert (is_gimple_omp_oacc (ctx->stmt));
 		s = TREE_TYPE (ovar);
-		if (TREE_CODE (s) == REFERENCE_TYPE
+		if (TYPE_REF_P (s)
 		    || omp_check_optional_argument (ovar, false))
 		  s = TREE_TYPE (s);
 		s = TYPE_SIZE_UNIT (s);
@@ -14046,7 +14046,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 		else if (TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
 		  {
 		    type = TREE_TYPE (OMP_CLAUSE_DECL (c));
-		    is_ref = TREE_CODE (type) == REFERENCE_TYPE;
+		    is_ref = TYPE_REF_P (type);
 		    new_var = build2 (MEM_REF, type,
 				      build_fold_addr_expr (new_var),
 				      build_int_cst (build_pointer_type (type),
@@ -14076,7 +14076,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 		    new_var = decl2;
 		    type = TREE_TYPE (new_var);
 		  }
-		else if (TREE_CODE (type) == REFERENCE_TYPE
+		else if (TYPE_REF_P (type)
 			 && TREE_CODE (TREE_TYPE (type)) == POINTER_TYPE)
 		  {
 		    type = TREE_TYPE (type);
@@ -14617,8 +14617,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 	  tree lhs = get_base_address (gimple_assign_lhs (stmt));
 	  if (TREE_CODE (lhs) == MEM_REF
 	      && DECL_P (TREE_OPERAND (lhs, 0))
-	      && TREE_CODE (TREE_TYPE (TREE_OPERAND (lhs,
-						     0))) == REFERENCE_TYPE)
+	      && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (lhs, 0))))
 	    lhs = TREE_OPERAND (lhs, 0);
 	  if (DECL_P (lhs))
 	    if (tree *v = up->lastprivate_conditional_map->get (lhs))
diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index c1cb7cc8a5c..a3046ed44d2 100644
--- a/gcc/omp-simd-clone.cc
+++ b/gcc/omp-simd-clone.cc
@@ -365,7 +365,7 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses,
 	    if (OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (t))
 	      {
 		enum cgraph_simd_clone_arg_type arg_type;
-		if (TREE_CODE (args[argno]) == REFERENCE_TYPE)
+		if (TYPE_REF_P (args[argno]))
 		  switch (OMP_CLAUSE_LINEAR_KIND (t))
 		    {
 		    case OMP_CLAUSE_LINEAR_REF:
@@ -410,7 +410,7 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses,
 		else
 		  {
 		    enum cgraph_simd_clone_arg_type arg_type;
-		    if (TREE_CODE (args[argno]) == REFERENCE_TYPE)
+		    if (TYPE_REF_P (args[argno]))
 		      switch (OMP_CLAUSE_LINEAR_KIND (t))
 			{
 			case OMP_CLAUSE_LINEAR_REF:
@@ -1392,7 +1392,7 @@ simd_clone_linear_addend (struct cgraph_node *node, unsigned int i,
       gsi_insert_before (&gsi, g, GSI_SAME_STMT);
       ret = gimple_assign_lhs (g);
     }
-  if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE)
+  if (TYPE_REF_P (TREE_TYPE (arg)))
     {
       g = gimple_build_assign (make_ssa_name (TREE_TYPE (TREE_TYPE (arg))),
 			       build_simple_mem_ref (ret));
@@ -1823,7 +1823,7 @@ simd_clone_adjust (struct cgraph_node *node)
 	tree orig_arg = node->simdclone->args[i].orig_arg;
 	tree def = ssa_default_def (cfun, orig_arg);
 	gcc_assert (!TREE_ADDRESSABLE (orig_arg)
-		    && TREE_CODE (TREE_TYPE (orig_arg)) == REFERENCE_TYPE);
+		    && TYPE_REF_P (TREE_TYPE (orig_arg)));
 	if (def && !has_zero_uses (def))
 	  {
 	    tree rtype = TREE_TYPE (TREE_TYPE (orig_arg));
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 954b39ae1c6..95c7c360529 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -432,7 +432,7 @@ remap_type_1 (tree type, copy_body_data *id)
       insert_decl_map (id, type, new_tree);
       return new_tree;
     }
-  else if (TREE_CODE (type) == REFERENCE_TYPE)
+  else if (TYPE_REF_P (type))
     {
       new_tree = build_reference_type_for_mode (remap_type (TREE_TYPE (type), id),
 					    TYPE_MODE (type),
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 420857b110c..634a1820613 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -10050,7 +10050,7 @@ reconstruct_complex_type (tree type, tree bottom)
       outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
 					   TYPE_REF_CAN_ALIAS_ALL (type));
     }
-  else if (TREE_CODE (type) == REFERENCE_TYPE)
+  else if (TYPE_REF_P (type))
     {
       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
       outer = build_reference_type_for_mode (inner, TYPE_MODE (type),
@@ -13387,7 +13387,7 @@ verify_type_variant (const_tree t, tree tv)
   /* FIXME: TYPE_SIZES_GIMPLIFIED may differs for Ada build.  */
   verify_variant_match (TYPE_UNSIGNED);
   verify_variant_match (TYPE_PACKED);
-  if (TREE_CODE (t) == REFERENCE_TYPE)
+  if (TYPE_REF_P (t))
     verify_variant_match (TYPE_REF_IS_RVALUE);
   if (AGGREGATE_TYPE_P (t))
     verify_variant_match (TYPE_REVERSE_STORAGE_ORDER);
@@ -14033,7 +14033,7 @@ verify_type (const_tree t)
 	  error_found = true;
 	}
     }
-  else if (TREE_CODE (t) == REFERENCE_TYPE)
+  else if (TYPE_REF_P (t))
     {
       if (TYPE_NEXT_REF_TO (t)
 	  && TREE_CODE (TYPE_NEXT_REF_TO (t)) != REFERENCE_TYPE)
@@ -14202,7 +14202,7 @@ verify_type (const_tree t)
   else if (TREE_CODE (t) == INTEGER_TYPE
 	   || TREE_CODE (t) == BOOLEAN_TYPE
 	   || TREE_CODE (t) == OFFSET_TYPE
-	   || TREE_CODE (t) == REFERENCE_TYPE
+	   || TYPE_REF_P (t)
 	   || TREE_CODE (t) == NULLPTR_TYPE
 	   || TREE_CODE (t) == POINTER_TYPE)
     {
@@ -14395,7 +14395,7 @@ nonnull_arg_p (const_tree arg)
     return true;
 
   /* Values passed by reference are always non-NULL.  */
-  if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE
+  if (TYPE_REF_P (TREE_TYPE (arg))
       && flag_delete_null_pointer_checks)
     return true;
 
diff --git a/gcc/tree.h b/gcc/tree.h
index ca3e0ce8f5e..d0d19153f91 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -687,7 +687,7 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
    ascending code order.  */
 
 #define POINTER_TYPE_P(TYPE) \
-  (TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)
+  (TREE_CODE (TYPE) == POINTER_TYPE || TYPE_REF_P (TYPE))
 
 /* Nonzero if TYPE represents a pointer to function.  */
 #define FUNCTION_POINTER_TYPE_P(TYPE) \
diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc
index d8dafa5481a..83e428fbc10 100644
--- a/gcc/var-tracking.cc
+++ b/gcc/var-tracking.cc
@@ -6282,7 +6282,7 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
 	{
 	  for (t = TYPE_ARG_TYPES (type); t && t != void_list_node;
 	       t = TREE_CHAIN (t))
-	    if (TREE_CODE (TREE_VALUE (t)) == REFERENCE_TYPE
+	    if (TYPE_REF_P (TREE_VALUE (t))
 		&& INTEGRAL_TYPE_P (TREE_TYPE (TREE_VALUE (t))))
 	      break;
 	  if ((t == NULL || t == void_list_node) && obj_type_ref == NULL_TREE)
@@ -6433,7 +6433,7 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
 	    function_arg_info arg (TREE_VALUE (t), /*named=*/true);
 	    apply_pass_by_reference_rules (&args_so_far_v, arg);
 	    reg = targetm.calls.function_arg (args_so_far, arg);
-	    if (TREE_CODE (arg.type) == REFERENCE_TYPE
+	    if (TYPE_REF_P (arg.type)
 		&& INTEGRAL_TYPE_P (TREE_TYPE (arg.type))
 		&& reg
 		&& REG_P (reg)
@@ -9870,7 +9870,7 @@ vt_add_function_parameter (tree parm)
       if (dv_is_value_p (dv))
 	{
 	  record_entry_value (CSELIB_VAL_PTR (dv_as_value (dv)), incoming);
-	  if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE
+	  if (TYPE_REF_P (TREE_TYPE (parm))
 	      && INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (parm))))
 	    {
 	      machine_mode indmode
-- 
2.41.0


  parent reply	other threads:[~2023-07-18 23:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 23:12 [PATCH 0/8] Tweak predicate macros in tree Ken Matsui
2023-07-18 23:12 ` [PATCH 1/8] c++, tree: Move TYPE_REF_P to tree.h Ken Matsui
2023-07-18 23:12 ` Ken Matsui [this message]
2023-07-18 23:12 ` [PATCH 3/8] c++, tree: Move TYPE_PTR_P " Ken Matsui
2023-07-18 23:12 ` [PATCH 4/8] c++, tree: Move INDIRECT_TYPE_P " Ken Matsui
2023-07-18 23:12 ` [PATCH 5/8] gcc: Use INDIRECT_TYPE_P instead of POINTER_TYPE_P Ken Matsui
2023-07-18 23:12 ` [PATCH 6/8] tree: Remove POINTER_TYPE_P Ken Matsui
2023-07-18 23:12 ` [PATCH 7/8] tree: Define TYPE_REF_IS_LVALUE Ken Matsui
2023-07-18 23:12 ` [PATCH 8/8] c++, lto: Use TYPE_REF_IS_LVALUE Ken Matsui
2023-07-19  7:07 ` [PATCH 0/8] Tweak predicate macros in tree Richard Biener
2023-07-19 17:27   ` Ken Matsui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230718233301.28677-3-kmatsui@gcc.gnu.org \
    --to=kmatsui@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).