+2018-05-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * cp-tree.h (TYPE_REF_P): New.
+ (TYPE_OBJ_P, TYPE_REF_OBJ_P, TYPE_REFFN_P): Update.
+ * call.c (build_list_conv, build_aggr_conv, standard_conversion,
+ direct_reference_binding, reference_binding, implicit_conversion,
+ add_builtin_candidate, build_user_type_conversion_1, build_op_call_1,
+ build_new_op_1, build_x_va_arg, conv_binds_ref_to_prvalue,
+ build_over_call, perform_implicit_conversion_flags,
+ extend_ref_init_temps, type_has_extended_temps): Use it.
+ * class.c (one_inheriting_sig, check_field_decls,
+ check_bases_and_members, find_flexarrays, finish_struct,
+ fixed_type_or_null): Likewise.
+ * constexpr.c (literal_type_p, cxx_bind_parameters_in_call,
+ non_const_var_error, cxx_eval_constant_expression,
+ potential_constant_expression_1): Likewise.
+ * cp-gimplify.c (omp_var_to_track, omp_cxx_notice_variable,
+ cp_genericize_r, cxx_omp_privatize_by_reference,
+ cxx_omp_const_qual_no_mutable, cxx_omp_finish_clause,
+ cp_fold_maybe_rvalue): Likewise.
+ * cp-ubsan.c (cp_ubsan_maybe_instrument_downcast): Likewise.
+ * cvt.c (build_up_reference, convert_to_reference,
+ convert_from_reference, convert_to_void, noexcept_conv_p,
+ fnptr_conv_p): Likewise.
+ * decl.c (poplevel, check_for_uninitialized_const_var,
+ check_initializer, initialize_local_var, cp_finish_decl,
+ get_tuple_decomp_init, cp_finish_decomp, grokdeclarator, copy_fn_p,
+ move_signature_fn_p, grok_op_properties, finish_function): Likewise.
+ * decl2.c (grok_array_decl, cp_reconstruct_complex_type,
+ decl_maybe_constant_var_p): Likewise.
+ * error.c (dump_type_prefix, dump_expr): Likewise.
+ * except.c (initialize_handler_parm, complete_ptr_ref_or_void_ptr_p,
+ is_admissible_throw_operand_or_catch_parameter): Likewise.
+ * expr.c (mark_use): Likewise.
+ * init.c (build_zero_init_1, build_value_init_noctor,
+ perform_member_init, diagnose_uninitialized_cst_or_ref_member_1,
+ build_new, build_delete): Likewise.
+ * lambda.c (build_lambda_object): Likewise.
+ * mangle.c (write_expression, write_template_arg): Likewise.
+ * method.c (forward_parm, do_build_copy_constructor,
+ do_build_copy_assign, build_stub_object, constructible_expr,
+ walk_field_subobs): Likewise.
+ * parser.c (cp_parser_omp_for_loop_init,
+ cp_parser_omp_declare_reduction_exprs,
+ cp_parser_omp_declare_reduction): Likewise.
+ * pt.c (convert_nontype_argument_function, convert_nontype_argument,
+ convert_template_argument, tsubst_pack_expansion,
+ tsubst_function_decl, tsubst_decl, tsubst, tsubst_copy_and_build,
+ maybe_adjust_types_for_deduction, check_cv_quals_for_unify, unify,
+ more_specialized_fn, invalid_nontype_parm_type_p, dependent_type_p_r,
+ value_dependent_expression_p, build_deduction_guide): Likewise.
+ * semantics.c (finish_handler_parms, finish_non_static_data_member,
+ finish_compound_literal, omp_privatize_field,
+ handle_omp_array_sections_1, handle_omp_array_sections,
+ cp_check_omp_declare_reduction, finish_omp_reduction_clause,
+ finish_omp_declare_simd_methods, cp_finish_omp_clause_depend_sink,
+ finish_omp_clauses, finish_decltype_type, capture_decltype,
+ finish_builtin_launder): Likewise.
+ * tree.c (lvalue_kind, cp_build_reference_type, move,
+ cp_build_qualified_type_real, stabilize_expr, stabilize_init): Likewise.
+ * typeck.c (cxx_safe_arg_type_equiv_p, build_class_member_access_expr,
+ cp_build_indirect_ref_1, convert_arguments, warn_for_null_address,
+ cp_build_addr_expr_1, maybe_warn_about_useless_cast,
+ build_static_cast_1, build_static_cast, build_reinterpret_cast_1,
+ build_const_cast_1, cp_build_c_cast, cp_build_modify_expr,
+ convert_for_initialization,
+ maybe_warn_about_returning_address_of_local, check_return_expr,
+ cp_type_quals, casts_away_constness, non_reference): Likewise.
+ * typeck2.c (cxx_readonly_error, store_init_value,
+ process_init_constructor_record, build_x_arrow, build_functional_cast,
+ add_exception_specifier): Likewise.
+
2018-05-14 Jason Merrill <jason@redhat.com>
* pt.c (tsubst) [ARRAY_TYPE]: Check valid_array_size_p.
flags |= LOOKUP_NO_NARROWING;
/* Can't make an array of these types. */
- if (TREE_CODE (elttype) == REFERENCE_TYPE
+ if (TYPE_REF_P (elttype)
|| TREE_CODE (elttype) == FUNCTION_TYPE
|| VOID_TYPE_P (elttype))
return NULL;
val = CONSTRUCTOR_ELT (ctor, i)->value;
else if (DECL_INITIAL (field))
val = get_nsdmi (field, /*ctor*/false, complain);
- else if (TREE_CODE (ftype) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (ftype))
/* Value-initialization of reference is ill-formed. */
return NULL;
else
tree qualified_to;
to = non_reference (to);
- if (TREE_CODE (from) == REFERENCE_TYPE)
+ if (TYPE_REF_P (from))
{
fromref = true;
from = TREE_TYPE (from);
{
tree t;
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
- gcc_assert (TREE_CODE (conv->type) != REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
+ gcc_assert (!TYPE_REF_P (conv->type));
t = TREE_TYPE (type);
skip:;
}
- if (TREE_CODE (from) == REFERENCE_TYPE)
+ if (TYPE_REF_P (from))
{
from = TREE_TYPE (from);
if (!TYPE_REF_IS_RVALUE (rfrom)
conv = build_identity_conv (tfrom, expr);
conv = direct_reference_binding (rto, conv);
- if (TREE_CODE (rfrom) == REFERENCE_TYPE)
+ if (TYPE_REF_P (rfrom))
/* Handle rvalue reference to function properly. */
conv->rvaluedness_matches_p
= (TYPE_REF_IS_RVALUE (rto) == TYPE_REF_IS_RVALUE (rfrom));
from = TREE_TYPE (expr);
}
- if (TREE_CODE (to) == REFERENCE_TYPE)
+ if (TYPE_REF_P (to))
conv = reference_binding (to, from, expr, c_cast_p, flags, complain);
else
conv = standard_conversion (to, from, expr, c_cast_p, flags, complain);
we need candidates for both of them. */
if (type2 && !same_type_p (type1, type2)
&& TREE_CODE (type1) == TREE_CODE (type2)
- && (TREE_CODE (type1) == REFERENCE_TYPE
+ && (TYPE_REF_P (type1)
|| (TYPE_PTR_P (type1) && TYPE_PTR_P (type2))
|| (TYPE_PTRDATAMEM_P (type1) && TYPE_PTRDATAMEM_P (type2))
|| TYPE_PTRMEMFUNC_P (type1)
type = TREE_TYPE (convs);
if (i == 0 && ref1
- && (TREE_CODE (type) != REFERENCE_TYPE
+ && (!TYPE_REF_P (type)
|| CP_TYPE_CONST_P (TREE_TYPE (type))))
continue;
- if (code == COND_EXPR && TREE_CODE (type) == REFERENCE_TYPE)
+ if (code == COND_EXPR && TYPE_REF_P (type))
vec_safe_push (types[i], type);
type = non_reference (type);
We represent this in the conversion sequence with an
rvalue conversion, which means a constructor call. */
- if (TREE_CODE (totype) != REFERENCE_TYPE
+ if (!TYPE_REF_P (totype)
&& !(convflags & LOOKUP_NO_TEMP_BIND))
cand->second_conv
= build_conv (ck_rvalue, totype, cand->second_conv);
find a direct binding, so don't even consider temporaries. If
we don't find a direct binding, the caller will try again to
look for a temporary binding. */
- if (TREE_CODE (totype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (totype))
convflags |= LOOKUP_NO_TEMP_BIND;
old_candidates = candidates;
if (TYPE_PTRFN_P (totype)
|| TYPE_REFFN_P (totype)
- || (TREE_CODE (totype) == REFERENCE_TYPE
+ || (TYPE_REF_P (totype)
&& TYPE_PTRFN_P (TREE_TYPE (totype))))
for (ovl_iterator iter (TREE_VALUE (convs)); iter; ++iter)
{
{
parmtype = TREE_VALUE (parmlist);
- if (TREE_CODE (parmtype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (parmtype))
parmtype = TREE_TYPE (parmtype);
if (TREE_CODE (TREE_TYPE (args[i])) == ENUMERAL_TYPE
&& (same_type_ignoring_top_level_qualifiers_p
expr = mark_lvalue_use (expr);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
error ("cannot receive reference type %qT through %<...%>", type);
return error_mark_node;
if (c->kind == ck_rvalue)
return true;
- if (c->kind == ck_user && TREE_CODE (c->type) != REFERENCE_TYPE)
+ if (c->kind == ck_user && !TYPE_REF_P (c->type))
return true;
if (c->kind == ck_identity && c->u.expr
&& TREE_CODE (c->u.expr) == TARGET_EXPR)
reference to the object’s type (possibly cv-qualified)...." */
gcc_assert (!(complain & tf_error));
tree ptype = convs[0]->type;
- if (TREE_CODE (ptype) != REFERENCE_TYPE
+ if (!TYPE_REF_P (ptype)
|| !TYPE_REF_IS_RVALUE (ptype)
|| CONVERSION_RANK (convs[0]) > cr_exact)
return error_mark_node;
/* For -Wformat undo the implicit passing by hidden reference
done by convert_arg_to_ellipsis. */
if (TREE_CODE (argarray[j]) == ADDR_EXPR
- && TREE_CODE (TREE_TYPE (argarray[j])) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (argarray[j])))
fargs[j] = TREE_OPERAND (argarray[j], 0);
else
fargs[j] = maybe_constant_value (argarray[j]);
targ = arg;
/* Strip the reference binding for the constructor parameter. */
if (CONVERT_EXPR_P (targ)
- && TREE_CODE (TREE_TYPE (targ)) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (targ)))
targ = TREE_OPERAND (targ, 0);
/* But don't strip any other reference bindings; binding a temporary to a
reference prevents copy elision. */
while ((CONVERT_EXPR_P (targ)
- && TREE_CODE (TREE_TYPE (targ)) != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (targ)))
|| TREE_CODE (targ) == NON_LVALUE_EXPR)
targ = TREE_OPERAND (targ, 0);
if (TREE_CODE (targ) == ADDR_EXPR)
void *p;
location_t loc = EXPR_LOC_OR_LOC (expr, input_location);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
expr = mark_lvalue_use (expr);
else
expr = mark_rvalue_use (expr);
tree type = TREE_TYPE (init);
if (processing_template_decl)
return init;
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
init = extend_ref_init_temps_1 (decl, init, cleanups);
else
{
type_has_extended_temps (tree type)
{
type = strip_array_types (type);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
return true;
if (CLASS_TYPE_P (type))
{
if (nparms == 0)
return;
if (nparms == 1
- && TREE_CODE (parms[0]) == REFERENCE_TYPE)
+ && TYPE_REF_P (parms[0]))
{
tree parm = TYPE_MAIN_VARIANT (TREE_TYPE (parms[0]));
if (parm == t || parm == DECL_CONTEXT (ctor))
"a member of a union", x);
continue;
}
- if (TREE_CODE (type) == REFERENCE_TYPE
+ if (TYPE_REF_P (type)
&& TREE_CODE (x) == FIELD_DECL)
{
error ("non-static data member %q+D in a union may not "
CLASSTYPE_NON_STD_LAYOUT (t) = 1;
/* If this is of reference type, check if it needs an init. */
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
CLASSTYPE_NON_LAYOUT_POD_P (t) = 1;
CLASSTYPE_NON_STD_LAYOUT (t) = 1;
"and %<mutable%>", x);
continue;
}
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
error ("member %q+D cannot be declared as a %<mutable%> "
"reference", x);
continue;
type = TREE_TYPE (field);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
warning_at (DECL_SOURCE_LOCATION (field),
OPT_Wuninitialized, "non-static reference %q#D "
"in class without a constructor", field);
members if it hasn't been yet. */
tree eltype = fldtype;
while (TREE_CODE (eltype) == ARRAY_TYPE
- || TREE_CODE (eltype) == POINTER_TYPE
- || TREE_CODE (eltype) == REFERENCE_TYPE)
+ || TYPE_PTR_P (eltype)
+ || TYPE_REF_P (eltype))
eltype = TREE_TYPE (eltype);
if (RECORD_OR_UNION_TYPE_P (eltype))
if (processing_template_decl)
{
tree f = next_initializable_field (TYPE_FIELDS (t));
- if (f && TREE_CODE (TREE_TYPE (f)) == POINTER_TYPE)
+ if (f && TYPE_PTR_P (TREE_TYPE (f)))
{
f = next_initializable_field (DECL_CHAIN (f));
if (f && same_type_p (TREE_TYPE (f), size_type_node))
return TREE_TYPE (TREE_TYPE (instance));
}
}
- else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (TREE_TYPE (instance)))
{
/* We only need one hash table because it is always left empty. */
if (!fixed_type_or_null_ref_ht)
{
if (SCALAR_TYPE_P (t)
|| VECTOR_TYPE_P (t)
- || TREE_CODE (t) == REFERENCE_TYPE
+ || TYPE_REF_P (t)
|| (VOID_TYPE_P (t) && cxx_dialect >= cxx14))
return true;
if (CLASS_TYPE_P (t))
arg = unshare_constructor (arg);
/* Make sure the binding has the same type as the parm. But
only for constant args. */
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
arg = adjust_temp_type (type, arg);
if (!TREE_CONSTANT (arg))
*non_constant_args = true;
else
gcc_unreachable ();
}
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
inform (DECL_SOURCE_LOCATION (r),
"%qD was not initialized with a constant "
"expression", r);
}
if (TREE_CODE (t) == INTEGER_CST
- && TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE
+ && TYPE_PTR_P (TREE_TYPE (t))
&& !integer_zerop (t))
{
if (!ctx->quiet)
return t;
case PARM_DECL:
- if (lval && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE)
+ if (lval && !TYPE_REF_P (TREE_TYPE (t)))
/* glvalue use. */;
else if (tree *p = ctx->values->get (r))
r = *p;
else if (lval)
/* Defer in case this is only used for its type. */;
- else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (TREE_TYPE (t)))
/* Defer, there's no lvalue->rvalue conversion. */;
else if (COMPLETE_TYPE_P (TREE_TYPE (t))
&& is_really_empty_class (TREE_TYPE (t)))
{
if (integer_zerop (op))
{
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
*non_constant_p = true;
return t;
}
- else if (TREE_CODE (TREE_TYPE (op)) == POINTER_TYPE)
+ else if (TYPE_PTR_P (TREE_TYPE (op)))
{
tree from = TREE_TYPE (op);
}
return (RECUR (TREE_OPERAND (t, 0),
- TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE));
+ !TYPE_REF_P (TREE_TYPE (t))));
case BIND_EXPR:
return RECUR (BIND_EXPR_BODY (t), want_rval);
tree type = TREE_TYPE (decl);
if (is_invisiref_parm (decl))
type = TREE_TYPE (type);
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
type = TREE_TYPE (type);
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
tree type = TREE_TYPE (decl);
if (is_invisiref_parm (decl))
type = TREE_TYPE (type);
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
type = TREE_TYPE (type);
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
}
if (TREE_CODE (stmt) == INTEGER_CST
- && TREE_CODE (TREE_TYPE (stmt)) == REFERENCE_TYPE
+ && TYPE_REF_P (TREE_TYPE (stmt))
&& (flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT))
&& !wtd->no_sanitize_p)
{
case NOP_EXPR:
if (!wtd->no_sanitize_p
&& sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT)
- && TREE_CODE (TREE_TYPE (stmt)) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (stmt)))
ubsan_maybe_instrument_reference (stmt_p);
break;
else if (fn == NULL_TREE
&& CALL_EXPR_IFN (stmt) == IFN_UBSAN_NULL
&& TREE_CODE (CALL_EXPR_ARG (stmt, 0)) == INTEGER_CST
- && (TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (stmt, 0)))
- == REFERENCE_TYPE))
+ && TYPE_REF_P (TREE_TYPE (CALL_EXPR_ARG (stmt, 0))))
*walk_subtrees = 0;
}
/* Fall through. */
bool
cxx_omp_privatize_by_reference (const_tree decl)
{
- return (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+ return (TYPE_REF_P (TREE_TYPE (decl))
|| is_invisiref_parm (decl));
}
cxx_omp_const_qual_no_mutable (tree decl)
{
tree type = TREE_TYPE (decl);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (!is_invisiref_parm (decl))
return false;
inner_type = TREE_TYPE (decl);
if (decl == error_mark_node)
make_shared = true;
- else if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (TREE_TYPE (decl)))
inner_type = TREE_TYPE (inner_type);
/* We're interested in the base element, not arrays. */
{
x = cp_fold (x);
if (rval && DECL_P (x)
- && TREE_CODE (TREE_TYPE (x)) != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (x)))
{
tree v = decl_constant_value (x);
if (v != x && v != error_mark_node)
#define REFERENCE_REF_P(NODE) \
(INDIRECT_REF_P (NODE) \
&& TREE_TYPE (TREE_OPERAND (NODE, 0)) \
- && (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \
- == REFERENCE_TYPE))
+ && TYPE_REF_P (TREE_TYPE (TREE_OPERAND ((NODE), 0))))
/* True if NODE is a REFERENCE_TYPE which is OK to instantiate to be a
reference to VLA type, because it's used for VLA capture. */
/* Returns true if NODE is a pointer-to-data-member. */
#define TYPE_PTRDATAMEM_P(NODE) \
(TREE_CODE (NODE) == OFFSET_TYPE)
+
/* Returns true if NODE is a pointer. */
#define TYPE_PTR_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE)
+/* Returns true if NODE is a reference. */
+#define TYPE_REF_P(NODE) \
+ (TREE_CODE (NODE) == REFERENCE_TYPE)
+
/* Returns true if NODE is an object type:
[basic.types]
Keep these checks in ascending order, for speed. */
#define TYPE_OBJ_P(NODE) \
- (TREE_CODE (NODE) != REFERENCE_TYPE \
+ (!TYPE_REF_P (NODE) \
&& !VOID_TYPE_P (NODE) \
&& TREE_CODE (NODE) != FUNCTION_TYPE \
&& TREE_CODE (NODE) != METHOD_TYPE)
/* Returns true if NODE is a reference to an object. Keep these checks
in ascending tree code order. */
#define TYPE_REF_OBJ_P(NODE) \
- (TREE_CODE (NODE) == REFERENCE_TYPE && TYPE_OBJ_P (TREE_TYPE (NODE)))
+ (TYPE_REF_P (NODE) && TYPE_OBJ_P (TREE_TYPE (NODE)))
/* Returns true if NODE is a pointer to an object, or a pointer to
void. Keep these checks in ascending tree code order. */
/* Returns true if NODE is a reference to function type. */
#define TYPE_REFFN_P(NODE) \
- (TREE_CODE (NODE) == REFERENCE_TYPE \
+ (TYPE_REF_P (NODE) \
&& TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
/* Returns true if NODE is a pointer to member function type. */
return NULL_TREE;
return cp_ubsan_maybe_instrument_vptr (loc, op, TREE_TYPE (type), true,
- TREE_CODE (type) == POINTER_TYPE
+ TYPE_PTR_P (type)
? UBSAN_DOWNCAST_POINTER
: UBSAN_DOWNCAST_REFERENCE);
}
tree argtype = TREE_TYPE (arg);
tree target_type = TREE_TYPE (type);
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
if ((flags & DIRECT_BIND) && ! lvalue_p (arg))
{
intype = TREE_TYPE (expr);
- gcc_assert (TREE_CODE (intype) != REFERENCE_TYPE);
- gcc_assert (TREE_CODE (reftype) == REFERENCE_TYPE);
+ gcc_assert (!TYPE_REF_P (intype));
+ gcc_assert (TYPE_REF_P (reftype));
intype = TYPE_MAIN_VARIANT (intype);
convert_from_reference (tree val)
{
if (TREE_TYPE (val)
- && TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (val)))
{
tree t = TREE_TYPE (TREE_TYPE (val));
tree ref = build1 (INDIRECT_REF, t, val);
case INDIRECT_REF:
{
tree type = TREE_TYPE (expr);
- int is_reference = TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0)))
- == REFERENCE_TYPE;
+ int is_reference = TYPE_REF_P (TREE_TYPE (TREE_OPERAND (expr, 0)));
int is_volatile = TYPE_VOLATILE (type);
int is_complete = COMPLETE_TYPE_P (complete_type (type));
t = TYPE_PTRMEMFUNC_FN_TYPE (t);
f = TYPE_PTRMEMFUNC_FN_TYPE (f);
}
- if (TREE_CODE (t) == POINTER_TYPE
- && TREE_CODE (f) == POINTER_TYPE)
+ if (TYPE_PTR_P (t)
+ && TYPE_PTR_P (f))
{
t = TREE_TYPE (t);
f = TREE_TYPE (f);
t = TYPE_PTRMEMFUNC_FN_TYPE (t);
f = TYPE_PTRMEMFUNC_FN_TYPE (f);
}
- if (TREE_CODE (t) == POINTER_TYPE
- && TREE_CODE (f) == POINTER_TYPE)
+ if (TYPE_PTR_P (t)
+ && TYPE_PTR_P (f))
{
t = TREE_TYPE (t);
f = TREE_TYPE (f);
}
else if (DECL_CONTEXT (decl) == current_function_decl
// For -Wunused-but-set-variable leave references alone.
- && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE
+ && !TYPE_REF_P (TREE_TYPE (decl))
&& errorcount == unused_but_set_errorcount)
{
if (!DECL_NAME (decl) && DECL_DECOMPOSITION_P (decl))
external linkage and must be initialized. ($8.4; $12.1)'' ARM
7.1.6 */
if (VAR_P (decl)
- && TREE_CODE (type) != REFERENCE_TYPE
+ && !TYPE_REF_P (type)
&& (constexpr_context_p
|| CP_TYPE_CONST_P (type) || var_in_constexpr_fn (decl))
&& !DECL_NONTRIVIALLY_INITIALIZED_P (decl))
if (TREE_CODE (decl) == CONST_DECL)
{
- gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
+ gcc_assert (!TYPE_REF_P (type));
DECL_INITIAL (decl) = init;
else if (!init && DECL_REALLY_EXTERN (decl))
;
else if (init || type_build_ctor_call (type)
- || TREE_CODE (type) == REFERENCE_TYPE)
+ || TYPE_REF_P (type))
{
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
init = grok_reference_init (decl, type, init, flags);
flags |= LOOKUP_ALREADY_DIGESTED;
gcc_assert (TREE_OPERAND (init, 0) == decl);
DECL_INITIAL (decl) = rinit;
- if (warn_init_self && TREE_CODE (type) == REFERENCE_TYPE)
+ if (warn_init_self && TYPE_REF_P (type))
{
STRIP_NOPS (rinit);
if (rinit == decl)
/* If DECL is a reference, then we want to know whether init is a
reference constant; init_const_expr_p as passed tells us whether
it's an rvalue constant. */
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
init_const_expr_p = potential_constant_expression (init);
if (init_const_expr_p)
{
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = 1;
if (decl_maybe_constant_var_p (decl)
/* FIXME setting TREE_CONSTANT on refs breaks the back end. */
- && TREE_CODE (type) != REFERENCE_TYPE)
+ && !TYPE_REF_P (type))
TREE_CONSTANT (decl) = 1;
}
}
}
else if (init
&& init_const_expr_p
- && TREE_CODE (type) != REFERENCE_TYPE
+ && !TYPE_REF_P (type)
&& decl_maybe_constant_var_p (decl)
&& !(dep_init = value_dependent_init_p (init)))
{
/* A reference will be modified here, as it is initialized. */
if (! DECL_EXTERNAL (decl)
&& TREE_READONLY (decl)
- && TREE_CODE (type) == REFERENCE_TYPE)
+ && TYPE_REF_P (type))
{
was_readonly = 1;
TREE_READONLY (decl) = 0;
/* [The id-expression] e is an lvalue if the type of the entity e is an
lvalue reference and an xvalue otherwise. */
- if (TREE_CODE (etype) != REFERENCE_TYPE
+ if (!TYPE_REF_P (etype)
|| TYPE_REF_IS_RVALUE (etype))
e = move (e);
tree type = TREE_TYPE (decl);
tree dexp = decl;
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
dexp = convert_from_reference (dexp);
type = complete_type (TREE_TYPE (type));
/* Filter out pointers-to-references and references-to-references.
We can get these if a TYPE_DECL is used. */
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (declarator->kind != cdk_reference)
{
*/
if (VOID_TYPE_P (type))
/* We already gave an error. */;
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
{
if (declarator->u.reference.rvalue_ref)
/* Leave type alone. */;
/* DR1688 says that a `constexpr' specifier in combination with
`volatile' is valid. */
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
{
type_quals |= TYPE_QUAL_CONST;
type = cp_build_qualified_type (type, type_quals);
error ("const %qs cannot be declared %<mutable%>", name);
storage_class = sc_none;
}
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
{
permerror (input_location, "reference %qs cannot be declared "
"%<mutable%>", name);
/* Pass by value copy assignment operator. */
result = -1;
}
- else if (TREE_CODE (arg_type) == REFERENCE_TYPE
+ else if (TYPE_REF_P (arg_type)
&& !TYPE_REF_IS_RVALUE (arg_type)
&& TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)) == DECL_CONTEXT (d))
{
if (arg_type == error_mark_node)
return 0;
- if (TREE_CODE (arg_type) == REFERENCE_TYPE
+ if (TYPE_REF_P (arg_type)
&& TYPE_REF_IS_RVALUE (arg_type)
&& same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)),
DECL_CONTEXT (d)))
&& warn_conversion)
{
tree t = TREE_TYPE (name);
- int ref = (TREE_CODE (t) == REFERENCE_TYPE);
+ int ref = TYPE_REF_P (t);
if (ref)
t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
{
tree arg = TREE_VALUE (argtypes);
tree ret = TREE_TYPE (TREE_TYPE (decl));
- if (methodp || TREE_CODE (arg) == REFERENCE_TYPE)
+ if (methodp || TYPE_REF_P (arg))
arg = TREE_TYPE (arg);
arg = TYPE_MAIN_VARIANT (arg);
if (operator_code == PREINCREMENT_EXPR
|| operator_code == PREDECREMENT_EXPR)
{
- if (TREE_CODE (ret) != REFERENCE_TYPE
+ if (!TYPE_REF_P (ret)
|| !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (ret)), arg))
warning (OPT_Weffc__, "prefix %qD should return %qT", decl,
build_reference_type (arg));
|| operator_code == TRUNC_DIV_EXPR
|| operator_code == MULT_EXPR
|| operator_code == TRUNC_MOD_EXPR)
- && TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (TREE_TYPE (decl))))
warning (OPT_Weffc__, "%qD should return by value", decl);
return true;
&& !TREE_NO_WARNING (decl)
&& !DECL_IN_SYSTEM_HEADER (decl)
&& TREE_TYPE (decl) != error_mark_node
- && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE
+ && !TYPE_REF_P (TREE_TYPE (decl))
&& (!CLASS_TYPE_P (TREE_TYPE (decl))
|| !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))))
warning_at (DECL_SOURCE_LOCATION (decl),
if (array_expr == error_mark_node || index_exp == error_mark_node)
error ("ambiguous conversion for array subscript");
- if (TREE_CODE (TREE_TYPE (array_expr)) == POINTER_TYPE)
+ if (TYPE_PTR_P (TREE_TYPE (array_expr)))
array_expr = mark_rvalue_use (array_expr);
else
array_expr = mark_lvalue_use_nonread (array_expr);
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 = cp_reconstruct_complex_type (TREE_TYPE (type), bottom);
outer = build_reference_type_for_mode (inner, TYPE_MODE (type),
if (DECL_HAS_VALUE_EXPR_P (decl))
/* A proxy isn't constant. */
return false;
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
/* References can be constant. */;
else if (CP_TYPE_CONST_NON_VOLATILE_P (type)
&& INTEGRAL_OR_ENUMERATION_TYPE_P (type))
}
if (TYPE_PTR_P (t))
pp_star (pp);
- else if (TREE_CODE (t) == REFERENCE_TYPE)
- {
- if (TYPE_REF_IS_RVALUE (t))
- pp_ampersand_ampersand (pp);
- else
- pp_ampersand (pp);
- }
+ else if (TYPE_REF_P (t))
+ {
+ if (TYPE_REF_IS_RVALUE (t))
+ pp_ampersand_ampersand (pp);
+ else
+ pp_ampersand (pp);
+ }
pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (pp, t);
}
if (!is_this_parameter (ob))
{
dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
- if (TREE_CODE (TREE_TYPE (ob)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (ob)))
pp_cxx_dot (pp);
else
pp_cxx_arrow (pp);
shouldn't print the `&' doing so indicates to the user
that the expression has pointer type. */
|| (TREE_TYPE (t)
- && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
+ && TYPE_REF_P (TREE_TYPE (t))))
dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
else if (TREE_CODE (TREE_OPERAND (t, 0)) == LABEL_DECL)
dump_unary_op (pp, "&&", t, flags);
&& same_type_p (TREE_TYPE (optype),
TREE_TYPE (ttype)))
{
- if (TREE_CODE (ttype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (ttype))
{
STRIP_NOPS (op);
if (TREE_CODE (op) == ADDR_EXPR)
/* Since pointers are passed by value, initialize a reference to
pointer catch parm with the address of the temporary. */
- if (TREE_CODE (init_type) == REFERENCE_TYPE
+ if (TYPE_REF_P (init_type)
&& TYPE_PTR_P (TREE_TYPE (init_type)))
exp = cp_build_addr_expr (exp, tf_warning_or_error);
/* Or a pointer or ref to one, or cv void *. */
is_ptr = TYPE_PTR_P (type);
- if (is_ptr || TREE_CODE (type) == REFERENCE_TYPE)
+ if (is_ptr || TYPE_REF_P (type))
{
tree core = TREE_TYPE (type);
else if (abstract_virtuals_error (is_throw ? ACU_THROW : ACU_CATCH, type))
return false;
else if (!is_throw
- && TREE_CODE (type) == REFERENCE_TYPE
+ && TYPE_REF_P (type)
&& TYPE_REF_IS_RVALUE (type))
{
error ("cannot declare catch parameter to be of rvalue "
}
expr = process_outer_var_ref (expr, tf_warning_or_error, true);
if (!(TREE_TYPE (oexpr)
- && TREE_CODE (TREE_TYPE (oexpr)) == REFERENCE_TYPE))
+ && TYPE_REF_P (TREE_TYPE (oexpr))))
expr = convert_from_reference (expr);
}
break;
{
/* Look through capture by reference. */
tree cap = DECL_CAPTURED_VARIABLE (ref);
- if (TREE_CODE (TREE_TYPE (cap)) != REFERENCE_TYPE
+ if (!TYPE_REF_P (TREE_TYPE (cap))
&& decl_constant_var_p (cap))
{
tree val = RECUR (cap);
init = build_zero_cst (type);
else
{
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
init = build_zero_cst (type);
}
error ("value-initialization of function type %qT", type);
return error_mark_node;
}
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
{
if (complain & tf_error)
error ("value-initialization of reference type %qT", type);
}
}
else if (init
- && (TREE_CODE (type) == REFERENCE_TYPE
+ && (TYPE_REF_P (type)
/* Pre-digested NSDMI. */
|| (((TREE_CODE (init) == CONSTRUCTOR
&& TREE_TYPE (init) == type)
{
tree core_type;
/* member traversal: note it leaves init NULL */
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
"uninitialized reference member in %q#T", type))
if (type_has_user_provided_constructor (field_type))
continue;
- if (TREE_CODE (field_type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (field_type))
{
++ error_count;
if (complain)
/* ``A reference cannot be created by the new operator. A reference
is not an object (8.2.2, 8.4.3), so a pointer to it could not be
returned by new.'' ARM 5.3.3 */
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (complain & tf_error)
error ("new cannot be applied to a reference type");
if (type == error_mark_node)
return error_mark_node;
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
if (TREE_CODE (type) == ARRAY_TYPE)
val = build_array_copy (val);
else if (DECL_NORMAL_CAPTURE_P (field)
&& !DECL_VLA_CAPTURE_P (field)
- && TREE_CODE (TREE_TYPE (field)) != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (field)))
{
/* "the entities that are captured by copy are used to
direct-initialize each corresponding non-static data
}
else if (INDIRECT_REF_P (expr)
&& TREE_TYPE (TREE_OPERAND (expr, 0))
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (expr, 0))))
{
write_expression (TREE_OPERAND (expr, 0));
}
don't actually want to output a mangling code for the `&'. */
if (TREE_CODE (expr) == ADDR_EXPR
&& TREE_TYPE (expr)
- && TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (expr)))
{
expr = TREE_OPERAND (expr, 0);
if (DECL_P (expr))
if (REFERENCE_REF_P (node))
node = TREE_OPERAND (node, 0);
if (TREE_CODE (node) == NOP_EXPR
- && TREE_CODE (TREE_TYPE (node)) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (node)))
{
/* Template parameters can be of reference type. To maintain
internal consistency, such arguments use a conversion from
tree type = TREE_TYPE (parm);
if (DECL_PACK_P (parm))
type = PACK_EXPANSION_PATTERN (type);
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
type = cp_build_reference_type (type, /*rval=*/true);
warning_sentinel w (warn_useless_cast);
exp = build_static_cast (type, exp, tf_warning_or_error);
the field is "T", then the type will usually be "const
T". (There are no cv-qualified variants of reference
types.) */
- if (TREE_CODE (expr_type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (expr_type))
{
int quals = cvquals;
}
init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
- if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
+ if (move_p && !TYPE_REF_P (expr_type)
/* 'move' breaks bit-fields, and has no effect for scalars. */
&& !scalarish_type_p (expr_type))
init = move (init);
"assignment operator", field);
continue;
}
- else if (TREE_CODE (expr_type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (expr_type))
{
error ("non-static reference member %q#D, can%'t use "
"default assignment operator", field);
expr_type = cp_build_qualified_type (expr_type, quals);
init = build3 (COMPONENT_REF, expr_type, init, field, NULL_TREE);
- if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
+ if (move_p && !TYPE_REF_P (expr_type)
/* 'move' breaks bit-fields, and has no effect for scalars. */
&& !scalarish_type_p (expr_type))
init = move (init);
static tree
build_stub_object (tree reftype)
{
- if (TREE_CODE (reftype) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (reftype))
reftype = cp_build_reference_type (reftype, /*rval*/true);
tree stub = build1 (CONVERT_EXPR, reftype, integer_one_node);
return convert_from_reference (stub);
tree ctype = to;
vec<tree, va_gc> *args = NULL;
cp_unevaluated cp_uneval_guard;
- if (TREE_CODE (to) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (to))
to = cp_build_reference_type (to, /*rval*/false);
tree ob = build_stub_object (to);
for (; from; from = TREE_CHAIN (from))
error ("non-static const member %q#D, can%'t use default "
"assignment operator", field);
}
- else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (mem_type))
{
if (diag)
error ("non-static reference member %q#D, can%'t use "
}
bad = true;
}
- else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (mem_type))
{
if (diag)
{
else if (sfk == sfk_copy_constructor)
{
/* 12.8p11b5 */
- if (TREE_CODE (mem_type) == REFERENCE_TYPE
+ if (TYPE_REF_P (mem_type)
&& TYPE_REF_IS_RVALUE (mem_type))
{
if (diag)
init = cp_parser_assignment_expression (parser);
non_class:
- if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (decl)))
init = error_mark_node;
else
cp_finish_decl (decl, NULL_TREE,
cp_parser_omp_declare_reduction_exprs (tree fndecl, cp_parser *parser)
{
tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
type = TREE_TYPE (type);
tree omp_out = build_lang_decl (VAR_DECL, get_identifier ("omp_out"), type);
DECL_ARTIFICIAL (omp_out) = 1;
|| TREE_CODE (type) == ARRAY_TYPE)
error_at (loc, "function or array type %qT in "
"%<#pragma omp declare reduction%>", type);
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
error_at (loc, "reference type %qT in "
"%<#pragma omp declare reduction%>", type);
else if (TYPE_QUALS_NO_ADDR_SPACE (type))
}
accept:
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (REFERENCE_REF_P (fn))
fn = TREE_OPERAND (fn, 0);
}
}
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
expr = mark_lvalue_use (expr);
else
expr = mark_rvalue_use (expr);
could actually change the type to something more cv-qualified,
and this is not folded by convert_from_reference. */
tree addr = TREE_OPERAND (probe, 0);
- if (TREE_CODE (probe_type) == REFERENCE_TYPE
+ if (TYPE_REF_P (probe_type)
&& TREE_CODE (addr) == ADDR_EXPR
&& TYPE_PTR_P (TREE_TYPE (addr))
&& (same_type_ignoring_top_level_qualifiers_p
const_tree inner = TREE_OPERAND (val, 0);
const_tree innertype = TREE_TYPE (inner);
if (innertype
- && TREE_CODE (innertype) == REFERENCE_TYPE
+ && TYPE_REF_P (innertype)
&& TREE_CODE (TREE_TYPE (innertype)) == FUNCTION_TYPE
&& TREE_OPERAND_LENGTH (inner) > 0
&& reject_gcc_builtin (TREE_OPERAND (inner, 0)))
/* Also optimize expression pack expansions if we can tell that the
elements won't have reference type. */
tree type = TREE_TYPE (pattern);
- if (type && TREE_CODE (type) != REFERENCE_TYPE
+ if (type && !TYPE_REF_P (type)
&& !PACK_EXPANSION_P (type)
&& !WILDCARD_TYPE_P (type))
return args;
tree argtype
= TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (t))));
argtype = tsubst (argtype, args, complain, in_decl);
- if (TREE_CODE (argtype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (argtype))
error_at (DECL_SOURCE_LOCATION (t),
"reference type %qT in "
"%<#pragma omp declare reduction%>", argtype);
/*constant_expression_p=*/false);
if (REFERENCE_REF_P (ve))
{
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
ve = TREE_OPERAND (ve, 0);
}
SET_DECL_VALUE_EXPR (r, ve);
Core issue 106 says that creating a reference to a reference
during instantiation is no longer a cause for failure. We
only enforce this check in strict C++98 mode. */
- if ((TREE_CODE (type) == REFERENCE_TYPE
+ if ((TYPE_REF_P (type)
&& (((cxx_dialect == cxx98) && flag_iso) || code != REFERENCE_TYPE))
|| (code == REFERENCE_TYPE && VOID_TYPE_P (type)))
{
if (TREE_CODE (type) == METHOD_TYPE)
r = build_ptrmemfunc_type (r);
}
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
/* In C++0x, during template argument substitution, when there is an
attempt to create a reference to a reference type, reference
collapsing is applied as described in [14.3.1/4 temp.arg.type]:
error ("creating pointer to member of non-class type %qT", r);
return error_mark_node;
}
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (complain & tf_error)
error ("creating pointer to member reference type %qT", type);
|| TREE_CODE (type) == FUNCTION_TYPE
|| (TREE_CODE (type) == ARRAY_TYPE
&& TYPE_DOMAIN (type) == NULL_TREE)
- || TREE_CODE (type) == REFERENCE_TYPE)
+ || TYPE_REF_P (type))
{
if (complain & tf_error)
error ("creating array of %qT", type);
else if (outer_automatic_var_p (r))
r = process_outer_var_ref (r, complain);
- if (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (TREE_TYPE (t)))
/* If the original type was a reference, we'll be wrapped in
the appropriate INDIRECT_REF. */
r = convert_from_reference (r);
/* Core issue #873: Do the DR606 thing (see below) for these cases,
too, but here handle it by stripping the reference from PARM
rather than by adding it to ARG. */
- if (TREE_CODE (*parm) == REFERENCE_TYPE
+ if (TYPE_REF_P (*parm)
&& TYPE_REF_IS_RVALUE (*parm)
&& TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM
&& cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED
- && TREE_CODE (*arg) == REFERENCE_TYPE
+ && TYPE_REF_P (*arg)
&& !TYPE_REF_IS_RVALUE (*arg))
*parm = TREE_TYPE (*parm);
/* Nothing else to do in this case. */
gcc_unreachable ();
}
- if (TREE_CODE (*parm) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (*parm))
{
/* [temp.deduct.call]
deduction (13.3.1.8)). If P is a forwarding reference and the argument is
an lvalue, the type "lvalue reference to A" is used in place of A for type
deduction. */
- if (TREE_CODE (*parm) == REFERENCE_TYPE
+ if (TYPE_REF_P (*parm)
&& TYPE_REF_IS_RVALUE (*parm)
&& TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM
&& !TEMPLATE_TYPE_PARM_FOR_CLASS (TREE_TYPE (*parm))
reference type, the type referred to by P is used for
type deduction. */
*parm = TYPE_MAIN_VARIANT (*parm);
- if (TREE_CODE (*parm) == REFERENCE_TYPE)
+ if (TYPE_REF_P (*parm))
{
*parm = TREE_TYPE (*parm);
result |= UNIFY_ALLOW_OUTER_MORE_CV_QUAL;
/* DR 322. For conversion deduction, remove a reference type on parm
too (which has been swapped into ARG). */
- if (strict == DEDUCE_CONV && TREE_CODE (*arg) == REFERENCE_TYPE)
+ if (strict == DEDUCE_CONV && TYPE_REF_P (*arg))
*arg = TREE_TYPE (*arg);
return result;
types are not of the form "cv-list T" [14.8.2.5 temp.deduct.type].
It is ok when we're allowing additional CV qualifiers
at the outer level [14.8.2.1]/3,1st bullet. */
- if ((TREE_CODE (arg) == REFERENCE_TYPE
+ if ((TYPE_REF_P (arg)
|| TREE_CODE (arg) == FUNCTION_TYPE
|| TREE_CODE (arg) == METHOD_TYPE)
&& (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)))
}
case REFERENCE_TYPE:
- if (TREE_CODE (arg) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (arg))
return unify_type_mismatch (explain_p, parm, arg);
return unify (tparms, targs, TREE_TYPE (parm), TREE_TYPE (arg),
strict & UNIFY_ALLOW_MORE_CV_QUAL, explain_p);
&& !uses_deducible_template_parms (arg2))
goto next;
- if (TREE_CODE (arg1) == REFERENCE_TYPE)
+ if (TYPE_REF_P (arg1))
{
ref1 = TYPE_REF_IS_RVALUE (arg1) + 1;
arg1 = TREE_TYPE (arg1);
quals1 = cp_type_quals (arg1);
}
- if (TREE_CODE (arg2) == REFERENCE_TYPE)
+ if (TYPE_REF_P (arg2))
{
ref2 = TYPE_REF_IS_RVALUE (arg2) + 1;
arg2 = TREE_TYPE (arg2);
return false;
else if (TYPE_PTR_P (type))
return false;
- else if (TREE_CODE (type) == REFERENCE_TYPE
+ else if (TYPE_REF_P (type)
&& !TYPE_REF_IS_RVALUE (type))
return false;
else if (TYPE_PTRMEM_P (type))
|| dependent_type_p (TYPE_PTRMEM_POINTED_TO_TYPE
(type)));
else if (TYPE_PTR_P (type)
- || TREE_CODE (type) == REFERENCE_TYPE)
+ || TYPE_REF_P (type))
return dependent_type_p (TREE_TYPE (type));
else if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE)
with an expression that is value-dependent. */
if (DECL_DEPENDENT_INIT_P (expression)
/* FIXME cp_finish_decl doesn't fold reference initializers. */
- || TREE_CODE (TREE_TYPE (expression)) == REFERENCE_TYPE)
+ || TYPE_REF_P (TREE_TYPE (expression)))
return true;
if (DECL_HAS_VALUE_EXPR_P (expression))
{
if (TYPE_P (ctor))
{
type = ctor;
- bool copy_p = TREE_CODE (type) == REFERENCE_TYPE;
+ bool copy_p = TYPE_REF_P (type);
if (copy_p)
{
type = TREE_TYPE (type);
if (warn_catch_value
&& type != NULL_TREE
&& type != error_mark_node
- && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (decl)))
{
tree orig_type = TREE_TYPE (decl);
if (CLASS_TYPE_P (orig_type))
{
tree type = TREE_TYPE (decl);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
/* Quals on the object don't matter. */;
else if (PACK_EXPANSION_P (type))
/* Don't bother trying to represent this. */
if (type == error_mark_node)
return error_mark_node;
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
compound_literal
= finish_compound_literal (TREE_TYPE (type), compound_literal,
return error_mark_node;
if (!omp_private_member_map && !shared)
omp_private_member_map = new hash_map<tree, tree>;
- if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (t)))
{
gcc_assert (INDIRECT_REF_P (m));
m = TREE_OPERAND (m, 0);
}
}
}
- else if (TREE_CODE (type) == POINTER_TYPE)
+ else if (TYPE_PTR_P (type))
{
if (length == NULL_TREE)
{
eltype = TREE_TYPE (eltype);
tree type = build_array_type (eltype, index_type);
tree ptype = build_pointer_type (eltype);
- if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
+ if (TYPE_REF_P (TREE_TYPE (t))
&& POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t))))
t = convert_from_reference (t);
else if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
OMP_CLAUSE_CHAIN (c) = c2;
ptr = OMP_CLAUSE_DECL (c2);
if (OMP_CLAUSE_MAP_KIND (c2) != GOMP_MAP_FIRSTPRIVATE_POINTER
- && TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE
+ && TYPE_REF_P (TREE_TYPE (ptr))
&& POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
{
tree c3 = build_omp_clause (OMP_CLAUSE_LOCATION (c),
cp_check_omp_declare_reduction (tree udr)
{
tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (udr)));
- gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+ gcc_assert (TYPE_REF_P (type));
type = TREE_TYPE (type);
int i;
location_t loc = DECL_SOURCE_LOCATION (udr);
"%<#pragma omp declare reduction%>", type);
return;
}
- else if (TREE_CODE (type) == REFERENCE_TYPE)
+ else if (TYPE_REF_P (type))
{
error_at (loc, "reference type %qT in %<#pragma omp declare reduction%>",
type);
tree type = TREE_TYPE (t);
if (TREE_CODE (t) == MEM_REF)
type = TREE_TYPE (type);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
type = TREE_TYPE (type);
if (TREE_CODE (type) == ARRAY_TYPE)
{
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[0])))
cxx_mark_addressable (placeholder);
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[1]))
- && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c)))
- != REFERENCE_TYPE)
+ && !TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c))))
cxx_mark_addressable (decl_placeholder ? decl_placeholder
: OMP_CLAUSE_DECL (c));
tree omp_out = placeholder;
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
&& integer_zerop (OMP_CLAUSE_DECL (c))
&& OMP_CLAUSE_LINEAR_STEP (c)
- && TREE_CODE (TREE_TYPE (OMP_CLAUSE_LINEAR_STEP (c)))
- == POINTER_TYPE)
+ && TYPE_PTR_P (TREE_TYPE (OMP_CLAUSE_LINEAR_STEP (c))))
{
tree s = OMP_CLAUSE_LINEAR_STEP (c);
s = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, s);
for (; t; t = TREE_CHAIN (t))
{
tree decl = TREE_VALUE (t);
- if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
+ if (TYPE_PTR_P (TREE_TYPE (decl)))
{
tree offset = TREE_PURPOSE (t);
bool neg = wi::neg_p (wi::to_wide (offset));
tree type = TREE_TYPE (t);
if ((OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
|| OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_UVAL)
- && TREE_CODE (type) != REFERENCE_TYPE)
+ && !TYPE_REF_P (type))
{
error ("linear clause with %qs modifier applied to "
"non-reference variable with %qT type",
remove = true;
break;
}
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
type = TREE_TYPE (type);
if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF)
{
if (!INTEGRAL_TYPE_P (type)
- && TREE_CODE (type) != POINTER_TYPE)
+ && !TYPE_PTR_P (type))
{
error ("linear clause applied to non-integral non-pointer"
" variable with %qT type", TREE_TYPE (t));
&& !INTEGRAL_TYPE_P (TREE_TYPE (t))
&& (ort != C_ORT_OMP_DECLARE_SIMD
|| TREE_CODE (t) != PARM_DECL
- || TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
+ || !TYPE_REF_P (TREE_TYPE (t))
|| !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t)))))
{
error ("linear step expression must be integral");
}
t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
tree type = TREE_TYPE (OMP_CLAUSE_DECL (c));
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
type = TREE_TYPE (type);
if (OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF)
{
break;
}
}
- else if (TREE_CODE (type) == POINTER_TYPE
+ else if (TYPE_PTR_P (type)
/* Can't multiply the step yet if *this
is still incomplete type. */
&& (ort != C_ORT_OMP_DECLARE_SIMD
remove = true;
}
else if (!type_dependent_expression_p (t)
- && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE
+ && !TYPE_PTR_P (TREE_TYPE (t))
&& TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE
- && (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
+ && (!TYPE_REF_P (TREE_TYPE (t))
|| (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t)))
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (t)))
!= ARRAY_TYPE))))
break;
}
else if (!processing_template_decl
- && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
+ && !TYPE_REF_P (TREE_TYPE (t))
&& (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
|| (OMP_CLAUSE_MAP_KIND (c)
!= GOMP_MAP_FIRSTPRIVATE_POINTER))
== GOMP_MAP_FIRSTPRIVATE_POINTER)))
&& t == OMP_CLAUSE_DECL (c)
&& !type_dependent_expression_p (t)
- && !cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t))
- == REFERENCE_TYPE)
+ && !cp_omp_mappable_type (TYPE_REF_P (TREE_TYPE (t))
? TREE_TYPE (TREE_TYPE (t))
: TREE_TYPE (t)))
{
if (!remove
&& !processing_template_decl
&& (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP
- && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c))))
{
t = OMP_CLAUSE_DECL (c);
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
if (!type_dependent_expression_p (t))
{
tree type = TREE_TYPE (t);
- if (TREE_CODE (type) != POINTER_TYPE
+ if (!TYPE_PTR_P (type)
&& TREE_CODE (type) != ARRAY_TYPE
- && (TREE_CODE (type) != REFERENCE_TYPE
- || (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
+ && (!TYPE_REF_P (type)
+ || (!TYPE_PTR_P (TREE_TYPE (type))
&& TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE)))
{
error_at (OMP_CLAUSE_LOCATION (c),
t = require_complete_type (t);
if (t == error_mark_node)
remove = true;
- else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
+ else if (TYPE_REF_P (TREE_TYPE (t))
&& !complete_type_or_else (TREE_TYPE (TREE_TYPE (t)), t))
remove = true;
}
if ((need_complete_type
|| need_copy_assignment
|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
- && TREE_CODE (inner_type) == REFERENCE_TYPE)
+ && TYPE_REF_P (inner_type))
inner_type = TREE_TYPE (inner_type);
while (TREE_CODE (inner_type) == ARRAY_TYPE)
inner_type = TREE_TYPE (inner_type);
decltype(e) is defined as T&; if an xvalue, T&&; otherwise, T. */
cp_lvalue_kind clk = lvalue_kind (expr);
type = unlowered_expr_type (expr);
- gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
+ gcc_assert (!TYPE_REF_P (type));
/* For vector types, pick a non-opaque variant. */
if (VECTOR_TYPE_P (type))
case CPLD_COPY:
type = TREE_TYPE (decl);
- if (TREE_CODE (type) == REFERENCE_TYPE
+ if (TYPE_REF_P (type)
&& TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
type = TREE_TYPE (type);
break;
case CPLD_REFERENCE:
type = TREE_TYPE (decl);
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
type = build_reference_type (TREE_TYPE (decl));
break;
gcc_unreachable ();
}
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
{
if (!LAMBDA_EXPR_MUTABLE_P (lam))
type = cp_build_qualified_type (type, (cp_type_quals (type)
if (error_operand_p (arg))
return error_mark_node;
if (!type_dependent_expression_p (arg)
- && TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE)
+ && !TYPE_PTR_P (TREE_TYPE (arg)))
{
error_at (loc, "non-pointer argument to %<__builtin_launder%>");
return error_mark_node;
return lvalue_kind (TREE_OPERAND (ref, 0));
if (TREE_TYPE (ref)
- && TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (ref)))
{
/* unnamed rvalue references are rvalues */
if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
if (to_type == error_mark_node)
return error_mark_node;
- if (TREE_CODE (to_type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (to_type))
{
rval = rval && TYPE_REF_IS_RVALUE (to_type);
to_type = TREE_TYPE (to_type);
move (tree expr)
{
tree type = TREE_TYPE (expr);
- gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
+ gcc_assert (!TYPE_REF_P (type));
type = cp_build_reference_type (type, /*rval*/true);
return build_static_cast (type, expr, tf_warning_or_error);
}
[dcl.ref], [dcl.fct]. This used to be an error, but as of DR 295
(in CD1) we always ignore extra cv-quals on functions. */
if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
- && (TREE_CODE (type) == REFERENCE_TYPE
+ && (TYPE_REF_P (type)
|| TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE))
{
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
}
}
/* There are no expressions with REFERENCE_TYPE, but there can be call
arguments with such a type; just treat it as a pointer. */
- else if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE
+ else if (TYPE_REF_P (TREE_TYPE (exp))
|| SCALAR_TYPE_P (TREE_TYPE (exp))
|| !glvalue_p (exp))
{
{
tree type = TREE_TYPE (ce->value);
tree subinit;
- if (TREE_CODE (type) == REFERENCE_TYPE
+ if (TYPE_REF_P (type)
|| SCALAR_TYPE_P (type))
ce->value = stabilize_expr (ce->value, &subinit);
else if (!stabilize_init (ce->value, &subinit))
t1 = TYPE_MAIN_VARIANT (t1);
t2 = TYPE_MAIN_VARIANT (t2);
- if (TREE_CODE (t1) == POINTER_TYPE
- && TREE_CODE (t2) == POINTER_TYPE)
+ if (TYPE_PTR_P (t1)
+ && TYPE_PTR_P (t2))
return true;
/* The signedness of the parameter matters only when an integral
/* Compute the type of the field, as described in [expr.ref]. */
type_quals = TYPE_UNQUALIFIED;
member_type = TREE_TYPE (member);
- if (TREE_CODE (member_type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (member_type))
{
type_quals = (cp_type_quals (member_type)
| cp_type_quals (object_type));
(TREE_TYPE (ptr), TREE_TYPE (current_class_ptr)))))
return current_class_ref;
- pointer = (TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE
+ pointer = (TYPE_REF_P (TREE_TYPE (ptr))
? ptr : decay_conversion (ptr, complain));
if (pointer == error_mark_node)
return error_mark_node;
Strip such NOP_EXPRs, since VAL is used in non-lvalue context. */
if (TREE_CODE (val) == NOP_EXPR
&& TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0))
- && (type == 0 || TREE_CODE (type) != REFERENCE_TYPE))
+ && (type == 0 || !TYPE_REF_P (type)))
val = TREE_OPERAND (val, 0);
- if (type == 0 || TREE_CODE (type) != REFERENCE_TYPE)
+ if (type == 0 || !TYPE_REF_P (type))
{
if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE
|| TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE
"be NULL", TREE_OPERAND (cop, 0));
if (CONVERT_EXPR_P (op)
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == REFERENCE_TYPE)
+ && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (op, 0))))
{
tree inner_op = op;
STRIP_NOPS (inner_op);
}
}
- if (TREE_CODE (argtype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (argtype))
{
tree type = build_pointer_type (TREE_TYPE (argtype));
arg = build1 (CONVERT_EXPR, type, arg);
if (INDIRECT_REF_P (arg))
{
arg = TREE_OPERAND (arg, 0);
- if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (arg)))
{
tree type = build_pointer_type (TREE_TYPE (TREE_TYPE (arg)));
arg = build1 (CONVERT_EXPR, type, arg);
gcc_assert (PTRMEM_OK_P (arg));
t = TREE_OPERAND (arg, 1);
- if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (t)))
{
if (complain & tf_error)
error ("cannot create pointer to reference member %qD", t);
if (warn_useless_cast
&& complain & tf_warning)
{
- if ((TREE_CODE (type) == REFERENCE_TYPE
+ if ((TYPE_REF_P (type)
&& (TYPE_REF_IS_RVALUE (type)
? xvalue_p (expr) : lvalue_p (expr))
&& same_type_p (TREE_TYPE (expr), TREE_TYPE (type)))
we want to avoid constructing a new D. The standard is not
completely clear about this issue, but our interpretation is
consistent with other compilers. */
- if (TREE_CODE (type) == REFERENCE_TYPE
+ if (TYPE_REF_P (type)
&& CLASS_TYPE_P (TREE_TYPE (type))
&& CLASS_TYPE_P (intype)
&& (TYPE_REF_IS_RVALUE (type) || lvalue_p (expr))
/* "A glvalue of type cv1 T1 can be cast to type rvalue reference to
cv2 T2 if cv2 T2 is reference-compatible with cv1 T1 (8.5.3)." */
- if (TREE_CODE (type) == REFERENCE_TYPE
+ if (TYPE_REF_P (type)
&& TYPE_REF_IS_RVALUE (type)
&& (clk = real_lvalue_p (expr))
&& reference_related_p (TREE_TYPE (type), intype)
If T is a reference type, the result is an lvalue; otherwise,
the result is an rvalue. */
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
{
result = rvalue (result);
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
- if (TREE_CODE (type) != REFERENCE_TYPE
+ if (!TYPE_REF_P (type)
&& TREE_CODE (expr) == NOP_EXPR
&& TREE_TYPE (expr) == TREE_TYPE (TREE_OPERAND (expr, 0)))
expr = TREE_OPERAND (expr, 0);
"reference to T2" if an expression of type "pointer to T1" can be
explicitly converted to the type "pointer to T2" using a
reinterpret_cast. */
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (type))
{
if (! lvalue_p (expr))
{
src_type = TREE_TYPE (expr);
/* Expressions do not really have reference types. */
- if (TREE_CODE (src_type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (src_type))
src_type = TREE_TYPE (src_type);
/* [expr.const.cast]
-- if T1 is a class type, a prvalue of type T1 can be explicitly
converted to an xvalue of type T2 using the cast const_cast<T2&&>. */
- if (TREE_CODE (dst_type) == REFERENCE_TYPE)
+ if (TYPE_REF_P (dst_type))
{
reference_type = dst_type;
if (!TYPE_REF_IS_RVALUE (dst_type)
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
- if (TREE_CODE (type) != REFERENCE_TYPE
+ if (!TYPE_REF_P (type)
&& TREE_CODE (value) == NOP_EXPR
&& TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
value = TREE_OPERAND (value, 0);
if (!CLASS_TYPE_P (type))
type = TYPE_MAIN_VARIANT (type);
result_type = TREE_TYPE (result);
- if (!CLASS_TYPE_P (result_type) && TREE_CODE (type) != REFERENCE_TYPE)
+ if (!CLASS_TYPE_P (result_type) && !TYPE_REF_P (type))
result_type = TYPE_MAIN_VARIANT (result_type);
/* If the type of RESULT does not match TYPE, perform a
const_cast to make it match. If the static_cast or
/* A binary op has been requested. Combine the old LHS
value with the RHS producing the value we should actually
store into the LHS. */
- gcc_assert (!((TREE_CODE (lhstype) == REFERENCE_TYPE
+ gcc_assert (!((TYPE_REF_P (lhstype)
&& MAYBE_CLASS_TYPE_P (TREE_TYPE (lhstype)))
|| MAYBE_CLASS_TYPE_P (lhstype)));
goto ret;
}
}
- gcc_assert (TREE_CODE (lhstype) != REFERENCE_TYPE);
- gcc_assert (TREE_CODE (TREE_TYPE (newrhs)) != REFERENCE_TYPE);
+ gcc_assert (!TYPE_REF_P (lhstype));
+ gcc_assert (!TYPE_REF_P (TREE_TYPE (newrhs)));
}
/* The left-hand side must be an lvalue. */
;
else if ((TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE
&& TREE_CODE (type) != ARRAY_TYPE
- && (TREE_CODE (type) != REFERENCE_TYPE
+ && (!TYPE_REF_P (type)
|| TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE))
|| (TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
&& !TYPE_REFFN_P (type))
|| TREE_CODE (whats_returned) == ARRAY_REF)
whats_returned = TREE_OPERAND (whats_returned, 0);
- if (TREE_CODE (valtype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (valtype))
{
if (TREE_CODE (whats_returned) == AGGR_INIT_EXPR
|| TREE_CODE (whats_returned) == TARGET_EXPR)
&& !(TREE_STATIC (whats_returned)
|| TREE_PUBLIC (whats_returned)))
{
- if (TREE_CODE (valtype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (valtype))
warning_at (DECL_SOURCE_LOCATION (whats_returned),
OPT_Wreturn_local_addr,
"reference to local variable %qD returned",
/* The function return type must be a reference to the current
class. */
- if (TREE_CODE (valtype) == REFERENCE_TYPE
+ if (TYPE_REF_P (valtype)
&& same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (valtype), TREE_TYPE (current_class_ref)))
{
quals = TYPE_QUALS (type);
/* METHOD and REFERENCE_TYPEs should never have quals. */
gcc_assert ((TREE_CODE (type) != METHOD_TYPE
- && TREE_CODE (type) != REFERENCE_TYPE)
+ && !TYPE_REF_P (type))
|| ((quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE))
== TYPE_UNQUALIFIED));
return quals;
static bool
casts_away_constness (tree t1, tree t2, tsubst_flags_t complain)
{
- if (TREE_CODE (t2) == REFERENCE_TYPE)
+ if (TYPE_REF_P (t2))
{
/* [expr.const.cast]
using a reference cast casts away constness if a cast from an
rvalue of type "pointer to T1" to the type "pointer to T2"
casts away constness. */
- t1 = (TREE_CODE (t1) == REFERENCE_TYPE ? TREE_TYPE (t1) : t1);
+ t1 = (TYPE_REF_P (t1) ? TREE_TYPE (t1) : t1);
return casts_away_constness (build_pointer_type (t1),
build_pointer_type (TREE_TYPE (t2)),
complain);
tree
non_reference (tree t)
{
- if (t && TREE_CODE (t) == REFERENCE_TYPE)
+ if (t && TYPE_REF_P (t))
t = TREE_TYPE (t);
return t;
}
"constant field %qD"),
arg);
else if (INDIRECT_REF_P (arg)
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
+ && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
&& (VAR_P (TREE_OPERAND (arg, 0))
|| TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
ERROR_FOR_ASSIGNMENT (G_("assignment of "
|| error_operand_p (value));
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init;
/* FIXME setting TREE_CONSTANT on refs breaks the back end. */
- if (TREE_CODE (type) != REFERENCE_TYPE)
+ if (!TYPE_REF_P (type))
TREE_CONSTANT (decl) = const_init && decl_maybe_constant_var_p (decl);
}
value = cp_fully_fold (value);
else
{
const_tree fldtype = TREE_TYPE (field);
- if (TREE_CODE (fldtype) == REFERENCE_TYPE)
+ if (TYPE_REF_P (fldtype))
{
if (complain & tf_error)
error ("member %qD is uninitialized reference", field);
if (processing_template_decl)
{
- if (type && TREE_CODE (type) == POINTER_TYPE
+ if (type && TYPE_PTR_P (type)
&& !dependent_scope_p (TREE_TYPE (type)))
/* Pointer to current instantiation, don't treat as dependent. */;
else if (type_dependent_expression_p (expr))
return error_mark_node;
}
- if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
+ if (TYPE_REF_P (TREE_TYPE (last_rval)))
last_rval = convert_from_reference (last_rval);
}
else
/* Diagnose this even in a template. We could also try harder
to give all the usual errors when the type and args are
non-dependent... */
- if (TREE_CODE (type) == REFERENCE_TYPE && !parms)
+ if (TYPE_REF_P (type) && !parms)
{
if (complain & tf_error)
error ("invalid value-initialization of reference type");
incomplete, or pointer or ref to incomplete other than pointer
to cv void. */
is_ptr = TYPE_PTR_P (core);
- if (is_ptr || TREE_CODE (core) == REFERENCE_TYPE)
+ if (is_ptr || TYPE_REF_P (core))
core = TREE_TYPE (core);
if (complain < 0)
ok = true;