+2018-05-24 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * cp-tree.h (INDIRECT_TYPE_P): New.
+ * call.c (build_trivial_dtor_call, maybe_warn_class_memaccess,
+ joust): Use it instead of POINTER_TYPE_P.
+ * class.c (update_vtable_entry_for_fn, find_flexarrays,
+ * fixed_type_or_null, resolves_to_fixed_type_p): Likewise.
+ * constexpr.c (cxx_eval_binary_expression, cxx_fold_indirect_ref,
+ * cxx_eval_increment_expression, potential_constant_expression_1):
+ Likewise.
+ * cp-gimplify.c (cp_gimplify_expr, cp_genericize_r): Likewise.
+ * cp-objcp-common.c (cxx_get_alias_set): Likewise.
+ * cp-ubsan.c (cp_ubsan_maybe_instrument_member_call,
+ cp_ubsan_maybe_instrument_downcast): Likewise.
+ * cvt.c (cp_convert_to_pointer, ocp_convert,
+ cp_get_fndecl_from_callee, maybe_warn_nodiscard, convert): Likewise.
+ * cxx-pretty-print.c (cxx_pretty_printer::abstract_declarator,
+ pp_cxx_offsetof_expression_1): Likewise.
+ * decl.c (grokparms, static_fn_type): Likewise.
+ * decl2.c (grokbitfield): Likewise.
+ * error.c (dump_expr): Likewise.
+ * except.c (initialize_handler_parm, check_noexcept_r): Likewise.
+ * init.c (warn_placement_new_too_small): Likewise.
+ * lambda.c (build_capture_proxy, add_capture): Likewise.
+ * parser.c (cp_parser_omp_for_loop): Likewise.
+ * pt.c (convert_nontype_argument, fn_type_unification,
+ uses_deducible_template_parms, check_cv_quals_for_unify,
+ dependent_type_p_r): Likewise.
+ * search.c (check_final_overrider): Likewise.
+ * semantics.c (handle_omp_array_sections, finish_omp_clauses,
+ finish_omp_for): Likewise.
+ * tree.c (cp_build_qualified_type_real): Likewise.
+ * typeck.c (build_class_member_access_expr,
+ finish_class_member_access_expr, build_x_indirect_ref,
+ cp_build_indirect_ref_1, cp_build_binary_op, build_const_cast_1):
+ Likewise.
+
2018-05-24 Jason Merrill <jason@redhat.com>
PR c++/85864 - literal template and default template arg.
return fold_convert (void_type_node, instance);
}
- if (POINTER_TYPE_P (TREE_TYPE (instance)))
+ if (INDIRECT_TYPE_P (TREE_TYPE (instance)))
{
if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (instance))))
goto no_clobber;
unsigned srcidx = !dstidx;
tree dest = (*args)[dstidx];
- if (!TREE_TYPE (dest) || !POINTER_TYPE_P (TREE_TYPE (dest)))
+ if (!TREE_TYPE (dest) || !INDIRECT_TYPE_P (TREE_TYPE (dest)))
return;
tree srctype = NULL_TREE;
case BUILT_IN_MEMPCPY:
/* Determine the type of the source object. */
srctype = TREE_TYPE ((*args)[srcidx]);
- if (!srctype || !POINTER_TYPE_P (srctype))
+ if (!srctype || !INDIRECT_TYPE_P (srctype))
srctype = void_type_node;
else
srctype = TREE_TYPE (srctype);
tree t = TREE_TYPE (TREE_TYPE (l->fn));
tree f = TREE_TYPE (TREE_TYPE (w->fn));
- if (TREE_CODE (t) == TREE_CODE (f) && POINTER_TYPE_P (t))
+ if (TREE_CODE (t) == TREE_CODE (f) && INDIRECT_TYPE_P (t))
{
t = TREE_TYPE (t);
f = TREE_TYPE (f);
else if (warn)
{
tree source = source_type (w->convs[0]);
- if (POINTER_TYPE_P (source))
+ if (INDIRECT_TYPE_P (source))
source = TREE_TYPE (source);
if (warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn)
&& warning (OPT_Wconversion, " for conversion from %qH to %qI",
over_return = TREE_TYPE (TREE_TYPE (overrider_target));
base_return = TREE_TYPE (TREE_TYPE (target_fn));
- if (POINTER_TYPE_P (over_return)
+ if (INDIRECT_TYPE_P (over_return)
&& TREE_CODE (over_return) == TREE_CODE (base_return)
&& CLASS_TYPE_P (TREE_TYPE (over_return))
&& CLASS_TYPE_P (TREE_TYPE (base_return))
members if it hasn't been yet. */
tree eltype = fldtype;
while (TREE_CODE (eltype) == ARRAY_TYPE
- || TYPE_PTR_P (eltype)
- || TYPE_REF_P (eltype))
+ || INDIRECT_TYPE_P (eltype))
eltype = TREE_TYPE (eltype);
if (RECORD_OR_UNION_TYPE_P (eltype))
switch (TREE_CODE (instance))
{
case INDIRECT_REF:
- if (POINTER_TYPE_P (TREE_TYPE (instance)))
+ if (INDIRECT_TYPE_P (TREE_TYPE (instance)))
return NULL_TREE;
else
return RECUR (TREE_OPERAND (instance, 0));
fixed = fixed_type_or_null (instance, nonnull, &cdtorp);
if (fixed == NULL_TREE)
return 0;
- if (POINTER_TYPE_P (t))
+ if (INDIRECT_TYPE_P (t))
t = TREE_TYPE (t);
if (!same_type_ignoring_top_level_qualifiers_p (t, fixed))
return 0;
*non_constant_p = true;
/* Don't VERIFY_CONSTANT if this might be dealing with a pointer to
a local array in a constexpr function. */
- bool ptr = POINTER_TYPE_P (TREE_TYPE (lhs));
+ bool ptr = INDIRECT_TYPE_P (TREE_TYPE (lhs));
if (!ptr)
VERIFY_CONSTANT (r);
return r;
STRIP_NOPS (sub);
subtype = TREE_TYPE (sub);
- if (!POINTER_TYPE_P (subtype))
+ if (!INDIRECT_TYPE_P (subtype))
return NULL_TREE;
if (TREE_CODE (sub) == ADDR_EXPR)
non_constant_p, overflow_p);
/* Don't VERIFY_CONSTANT if this might be dealing with a pointer to
a local array in a constexpr function. */
- bool ptr = POINTER_TYPE_P (TREE_TYPE (val));
+ bool ptr = INDIRECT_TYPE_P (TREE_TYPE (val));
if (!ptr)
VERIFY_CONSTANT (val);
/* The modified value. */
bool inc = (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR);
tree mod;
- if (POINTER_TYPE_P (type))
+ if (INDIRECT_TYPE_P (type))
{
/* The middle end requires pointers to use POINTER_PLUS_EXPR. */
offset = convert_to_ptrofftype (offset);
return cp_fold_convert (type, op);
}
- if (POINTER_TYPE_P (type) && TREE_CODE (op) == INTEGER_CST)
+ if (INDIRECT_TYPE_P (type) && TREE_CODE (op) == INTEGER_CST)
{
if (integer_zerop (op))
{
may change to something more specific to type-punning (DR 1312). */
{
tree from = TREE_OPERAND (t, 0);
- if (POINTER_TYPE_P (TREE_TYPE (t))
+ if (INDIRECT_TYPE_P (TREE_TYPE (t))
&& TREE_CODE (from) == INTEGER_CST
&& !integer_zerop (from))
{
{
/* If flag_strong_eval_order, evaluate the object argument first. */
tree fntype = TREE_TYPE (CALL_EXPR_FN (*expr_p));
- if (POINTER_TYPE_P (fntype))
+ if (INDIRECT_TYPE_P (fntype))
fntype = TREE_TYPE (fntype);
if (TREE_CODE (fntype) == METHOD_TYPE)
{
tree fn = CALL_EXPR_FN (stmt);
if (fn != NULL_TREE
&& !error_operand_p (fn)
- && POINTER_TYPE_P (TREE_TYPE (fn))
+ && INDIRECT_TYPE_P (TREE_TYPE (fn))
&& TREE_CODE (TREE_TYPE (TREE_TYPE (fn))) == METHOD_TYPE)
{
bool is_ctor
/* Punt on PMFs until we canonicalize functions properly. */
if (TYPE_PTRMEMFUNC_P (t)
- || (POINTER_TYPE_P (t)
+ || (INDIRECT_TYPE_P (t)
&& TYPE_PTRMEMFUNC_P (TREE_TYPE (t))))
return 0;
#define TYPE_REF_P(NODE) \
(TREE_CODE (NODE) == REFERENCE_TYPE)
+/* Returns true if NODE is a pointer or a reference. */
+#define INDIRECT_TYPE_P(NODE) \
+ (TYPE_PTR_P (NODE) || TYPE_REF_P (NODE))
+
/* Returns true if NODE is an object type:
[basic.types]
tree *opp = &CALL_EXPR_ARG (stmt, 0);
tree op = *opp;
if (op == error_mark_node
- || !POINTER_TYPE_P (TREE_TYPE (op)))
+ || !INDIRECT_TYPE_P (TREE_TYPE (op)))
return;
while (TREE_CODE (op) == COMPOUND_EXPR)
{
cp_ubsan_maybe_instrument_downcast (location_t loc, tree type,
tree intype, tree op)
{
- if (!POINTER_TYPE_P (type)
- || !POINTER_TYPE_P (intype)
- || !POINTER_TYPE_P (TREE_TYPE (op))
+ if (!INDIRECT_TYPE_P (type)
+ || !INDIRECT_TYPE_P (intype)
+ || !INDIRECT_TYPE_P (TREE_TYPE (op))
|| !CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (op)))
|| !is_properly_derived_from (TREE_TYPE (type), TREE_TYPE (intype)))
return NULL_TREE;
form = TREE_CODE (intype);
- if (POINTER_TYPE_P (intype))
+ if (INDIRECT_TYPE_P (intype))
{
intype = TYPE_MAIN_VARIANT (intype);
/* Ignore any integer overflow caused by the conversion. */
return ignore_overflows (converted, e);
}
- if (POINTER_TYPE_P (type) || TYPE_PTRMEM_P (type))
+ if (INDIRECT_TYPE_P (type) || TYPE_PTRMEM_P (type))
return cp_convert_to_pointer (type, e, dofold, complain);
if (code == VECTOR_TYPE)
{
tree type = TREE_TYPE (fn);
if (type == unknown_type_node)
return NULL_TREE;
- gcc_assert (POINTER_TYPE_P (type));
+ gcc_assert (INDIRECT_TYPE_P (type));
if (fold)
fn = maybe_constant_init (fn);
STRIP_NOPS (fn);
tree type = TREE_TYPE (callee);
if (TYPE_PTRMEMFUNC_P (type))
type = TYPE_PTRMEMFUNC_FN_TYPE (type);
- if (POINTER_TYPE_P (type))
+ if (INDIRECT_TYPE_P (type))
type = TREE_TYPE (type);
tree rettype = TREE_TYPE (type);
intype = TREE_TYPE (expr);
- if (POINTER_TYPE_P (type) && POINTER_TYPE_P (intype))
+ if (INDIRECT_TYPE_P (type) && INDIRECT_TYPE_P (intype))
return build_nop (type, expr);
return ocp_convert (type, expr, CONV_BACKEND_CONVERT,
{
if (TYPE_PTRMEM_P (t))
pp_cxx_right_paren (this);
- else if (POINTER_TYPE_P (t))
+ else if (INDIRECT_TYPE_P (t))
{
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
|| TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
{
case ARROW_EXPR:
if (TREE_CODE (TREE_OPERAND (t, 0)) == STATIC_CAST_EXPR
- && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))))
+ && INDIRECT_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))))
{
pp->type_id (TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))));
pp_cxx_separate_with (pp, ',');
}
else if (abstract_virtuals_error (decl, type))
any_error = 1; /* Seems like a good idea. */
- else if (cxx_dialect < cxx17 && POINTER_TYPE_P (type))
+ else if (cxx_dialect < cxx17 && INDIRECT_TYPE_P (type))
{
/* Before C++17 DR 393:
[dcl.fct]/6, parameter types cannot contain pointers
if (TYPE_PTRMEMFUNC_P (memfntype))
memfntype = TYPE_PTRMEMFUNC_FN_TYPE (memfntype);
- if (POINTER_TYPE_P (memfntype)
+ if (INDIRECT_TYPE_P (memfntype)
|| TREE_CODE (memfntype) == FUNCTION_DECL)
memfntype = TREE_TYPE (memfntype);
if (TREE_CODE (memfntype) == FUNCTION_TYPE)
return void_type_node;
if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))
- && (POINTER_TYPE_P (value)
+ && (INDIRECT_TYPE_P (value)
|| !dependent_type_p (TREE_TYPE (value))))
{
error ("bit-field %qD with non-integral type", value);
tree optype = TREE_TYPE (op);
if (TREE_CODE (ttype) != TREE_CODE (optype)
- && POINTER_TYPE_P (ttype)
- && POINTER_TYPE_P (optype)
+ && INDIRECT_TYPE_P (ttype)
+ && INDIRECT_TYPE_P (optype)
&& same_type_p (TREE_TYPE (optype),
TREE_TYPE (ttype)))
{
adjusted by value from __cxa_begin_catch. Others are returned by
reference. */
init_type = TREE_TYPE (decl);
- if (!POINTER_TYPE_P (init_type))
+ if (!INDIRECT_TYPE_P (init_type))
init_type = build_reference_type (init_type);
/* Since pointers are passed by value, initialize a reference to
We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */
tree fn = cp_get_callee (t);
tree type = TREE_TYPE (fn);
- gcc_assert (POINTER_TYPE_P (type));
+ gcc_assert (INDIRECT_TYPE_P (type));
type = TREE_TYPE (type);
STRIP_NOPS (fn);
}
tree opertype = TREE_TYPE (oper);
- if ((addr_expr || !POINTER_TYPE_P (opertype))
+ if ((addr_expr || !INDIRECT_TYPE_P (opertype))
&& (VAR_P (oper)
|| TREE_CODE (oper) == FIELD_DECL
|| TREE_CODE (oper) == PARM_DECL))
type = lambda_proxy_type (object);
- if (name == this_identifier && !POINTER_TYPE_P (type))
+ if (name == this_identifier && !INDIRECT_TYPE_P (type))
{
type = build_pointer_type (type);
type = cp_build_qualified_type (type, TYPE_QUAL_CONST);
if (id == this_identifier && !by_reference_p)
{
- gcc_assert (POINTER_TYPE_P (type));
+ gcc_assert (INDIRECT_TYPE_P (type));
type = TREE_TYPE (type);
initializer = cp_build_fold_indirect_ref (initializer);
}
if (real_decl
&& ((processing_template_decl
&& (TREE_TYPE (real_decl) == NULL_TREE
- || !POINTER_TYPE_P (TREE_TYPE (real_decl))))
+ || !INDIRECT_TYPE_P (TREE_TYPE (real_decl))))
|| CLASS_TYPE_P (TREE_TYPE (real_decl))))
incr = cp_parser_omp_for_incr (parser, real_decl);
else
"a variable", orig_expr, expr);
return NULL_TREE;
}
- if (POINTER_TYPE_P (expr_type))
+ if (INDIRECT_TYPE_P (expr_type))
{
if (complain & tf_error)
error ("%qE is not a valid template argument for %qT "
{
/* We're deducing for a call to the result of a template conversion
function. The parms we really want are in return_type. */
- if (POINTER_TYPE_P (return_type))
+ if (INDIRECT_TYPE_P (return_type))
return_type = TREE_TYPE (return_type);
parms = TYPE_ARG_TYPES (return_type);
}
/* T*
T&
T&& */
- if (POINTER_TYPE_P (type))
+ if (INDIRECT_TYPE_P (type))
return uses_deducible_template_parms (TREE_TYPE (type));
/* T[integer-constant ]
&& (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)))
return 0;
- if ((!POINTER_TYPE_P (arg) && TREE_CODE (arg) != TEMPLATE_TYPE_PARM)
+ if ((!INDIRECT_TYPE_P (arg) && TREE_CODE (arg) != TEMPLATE_TYPE_PARM)
&& (parm_quals & TYPE_QUAL_RESTRICT))
return 0;
}
return (dependent_type_p (TYPE_PTRMEM_CLASS_TYPE (type))
|| dependent_type_p (TYPE_PTRMEM_POINTED_TO_TYPE
(type)));
- else if (TYPE_PTR_P (type)
- || TYPE_REF_P (type))
+ else if (INDIRECT_TYPE_P (type))
return dependent_type_p (TREE_TYPE (type));
else if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE)
/* OK */;
else if ((CLASS_TYPE_P (over_return) && CLASS_TYPE_P (base_return))
|| (TREE_CODE (base_return) == TREE_CODE (over_return)
- && POINTER_TYPE_P (base_return)))
+ && INDIRECT_TYPE_P (base_return)))
{
/* Potentially covariant. */
unsigned base_quals, over_quals;
- fail = !POINTER_TYPE_P (base_return);
+ fail = !INDIRECT_TYPE_P (base_return);
if (!fail)
{
fail = cp_type_quals (base_return) != cp_type_quals (over_return);
tree type = build_array_type (eltype, index_type);
tree ptype = build_pointer_type (eltype);
if (TYPE_REF_P (TREE_TYPE (t))
- && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t))))
+ && INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (t))))
t = convert_from_reference (t);
else if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
t = build_fold_addr_expr (t);
ptrdiff_type_node, t);
tree ptr = OMP_CLAUSE_DECL (c2);
ptr = convert_from_reference (ptr);
- if (!POINTER_TYPE_P (TREE_TYPE (ptr)))
+ if (!INDIRECT_TYPE_P (TREE_TYPE (ptr)))
ptr = build_fold_addr_expr (ptr);
t = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
ptrdiff_type_node, t,
ptr = OMP_CLAUSE_DECL (c2);
if (OMP_CLAUSE_MAP_KIND (c2) != GOMP_MAP_FIRSTPRIVATE_POINTER
&& TYPE_REF_P (TREE_TYPE (ptr))
- && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
+ && INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
{
tree c3 = build_omp_clause (OMP_CLAUSE_LOCATION (c),
OMP_CLAUSE_MAP);
&& !TYPE_PTR_P (TREE_TYPE (t))
&& TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE
&& (!TYPE_REF_P (TREE_TYPE (t))
- || (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t)))
+ || (!INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (t)))
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (t)))
!= ARRAY_TYPE))))
{
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
&& OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FORCE_DEVICEPTR
&& !type_dependent_expression_p (t)
- && !POINTER_TYPE_P (TREE_TYPE (t)))
+ && !INDIRECT_TYPE_P (TREE_TYPE (t)))
{
error ("%qD is not a pointer variable", t);
remove = true;
case POSTINCREMENT_EXPR:
/* c_omp_for_incr_canonicalize_ptr() should have been
called to massage things appropriately. */
- gcc_assert (!POINTER_TYPE_P (TREE_TYPE (decl)));
+ gcc_assert (!INDIRECT_TYPE_P (TREE_TYPE (decl)));
OMP_CLAUSE_LINEAR_STEP (c) = build_int_cst (TREE_TYPE (decl), 1);
break;
case PREDECREMENT_EXPR:
case POSTDECREMENT_EXPR:
/* c_omp_for_incr_canonicalize_ptr() should have been
called to massage things appropriately. */
- gcc_assert (!POINTER_TYPE_P (TREE_TYPE (decl)));
+ gcc_assert (!INDIRECT_TYPE_P (TREE_TYPE (decl)));
OMP_CLAUSE_LINEAR_STEP (c)
= build_int_cst (TREE_TYPE (decl), -1);
break;
gcc_unreachable ();
}
stept = TREE_TYPE (decl);
- if (POINTER_TYPE_P (stept))
+ if (INDIRECT_TYPE_P (stept))
stept = sizetype;
step = fold_convert (stept, step);
if (TREE_CODE (incr) == MINUS_EXPR)
if ((type_quals & TYPE_QUAL_RESTRICT)
&& TREE_CODE (type) != TEMPLATE_TYPE_PARM
&& TREE_CODE (type) != TYPENAME_TYPE
- && !POINTER_TYPE_P (type))
+ && !INDIRECT_TYPE_P (type))
{
bad_quals |= TYPE_QUAL_RESTRICT;
type_quals &= ~TYPE_QUAL_RESTRICT;
{
if (complain & tf_error)
{
- if (POINTER_TYPE_P (object_type)
+ if (INDIRECT_TYPE_P (object_type)
&& CLASS_TYPE_P (TREE_TYPE (object_type)))
error ("request for member %qD in %qE, which is of pointer "
"type %qT (maybe you meant to use %<->%> ?)",
{
if (complain & tf_error)
{
- if (POINTER_TYPE_P (object_type)
+ if (INDIRECT_TYPE_P (object_type)
&& CLASS_TYPE_P (TREE_TYPE (object_type)))
error ("request for member %qD in %qE, which is of pointer "
"type %qT (maybe you meant to use %<->%> ?)",
if (processing_template_decl)
{
/* Retain the type if we know the operand is a pointer. */
- if (TREE_TYPE (expr) && POINTER_TYPE_P (TREE_TYPE (expr)))
+ if (TREE_TYPE (expr) && INDIRECT_TYPE_P (TREE_TYPE (expr)))
return build_min (INDIRECT_REF, TREE_TYPE (TREE_TYPE (expr)), expr);
if (type_dependent_expression_p (expr))
return build_min_nt_loc (loc, INDIRECT_REF, expr);
type = TREE_TYPE (pointer);
- if (POINTER_TYPE_P (type))
+ if (INDIRECT_TYPE_P (type))
{
/* [expr.unary.op]
type0 = TREE_TYPE (type0);
if (!TYPE_P (type1))
type1 = TREE_TYPE (type1);
- if (POINTER_TYPE_P (type0) && same_type_p (TREE_TYPE (type0), type1)
+ if (INDIRECT_TYPE_P (type0) && same_type_p (TREE_TYPE (type0), type1)
&& !(TREE_CODE (first_arg) == PARM_DECL
&& DECL_ARRAY_PARAMETER_P (first_arg)
&& warn_sizeof_array_argument)
if (valid_p)
*valid_p = false;
- if (!POINTER_TYPE_P (dst_type) && !TYPE_PTRDATAMEM_P (dst_type))
+ if (!INDIRECT_TYPE_P (dst_type) && !TYPE_PTRDATAMEM_P (dst_type))
{
if (complain & tf_error)
error ("invalid use of const_cast with type %qT, "