* call.c (add_builtin_candidate): Use TYPE_PTR_P and VOID_TYPE_P.
(build_op_call_1): Likewise.
(build_over_call): Likewise.
(compare_ics): Likewise.
* class.c (build_base_path): Likewise.
(resolve_address_of_overloaded_function): Likewise.
* cp-tree.h: Likewise.
* cvt.c (cp_convert_to_pointer): Likewise.
(convert_to_reference): Likewise.
(ocp_convert): Likewise.
(convert_force): Likewise, tidy.
* cxx-pretty-print.c (pp_cxx_postfix_expression): Likewise.
(pp_cxx_ptr_operator): Likewise.
* decl.c (duplicate_decls): Likewise.
(start_decl): Likewise.
(grok_op_properties): Likewise.
(start_preparsed_function): Likewise.
(store_parm_decls): Likewise.
(finish_function): Likewise.
* decl2.c (delete_sanity): Likewise.
(acceptable_java_type): Likewise.
(grokbitfield): Likewise.
(cp_reconstruct_complex_type): Likewise.
* error.c (dump_type_prefix): Likewise.
(dump_expr): Likewise.
* except.c (push_eh_cleanup): Likewise.
(complete_ptr_ref_or_void_ptr_p): Likewise.
(can_convert_eh): Likewise.
* init.c (build_new_1): Likewise.
(build_delete): Likewise.
(build_vec_delete): Likewise.
* mangle.c (write_type): Likewise.
* parser.c (lookup_literal_operator): Likewise.
* pt.c (convert_nontype_argument_function): Likewise.
(convert_nontype_argument): Likewise.
(tsubst): Likewise.
(unify): Likewise.
(dependent_type_p_r): Likewise.
* rtti.c (build_headof): Likewise.
(build_typeid): Likewise.
(build_dynamic_cast_1): Likewise.
(target_incomplete_p): Likewise.
(typeinfo_in_lib_p): Likewise.
* semantics.c (finish_omp_for): Likewise.
(cxx_eval_call_expression): Likewise.
(maybe_resolve_dummy): Likewise.
* tree.c (build_target_expr): Likewise.
(cp_build_qualified_type_real): Likewise.
* typeck.c (composite_pointer_type_r): Likewise.
(composite_pointer_type): Likewise.
(comp_except_types): Likewise.
(cxx_sizeof_nowarn): Likewise.
(string_conv_p): Likewise.
(cp_build_array_ref): Likewise.
(cp_build_function_call_vec): Likewise, also use TYPE_PTRFN_P.
(pointer_diff): Likewise.
(cp_build_addr_expr_1): Likewise.
(cp_build_unary_op): Likewise.
(build_static_cast_1): Likewise.
(cp_build_c_cast): Likewise.
(comp_ptr_ttypes_real): Likewise.
(ptr_reasonably_similar): Likewise.
(comp_ptr_ttypes_const): Likewise.
(casts_away_constness): Likewise.
(check_literal_operator_args): Likewise.
* typeck2.c (build_x_arrow): Likewise.
(add_exception_specifier): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197249
138bc75d-0d04-0410-961f-
82ee72b054a4
+2013-03-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * call.c (add_builtin_candidate): Use TYPE_PTR_P and VOID_TYPE_P.
+ (build_op_call_1): Likewise.
+ (build_over_call): Likewise.
+ (compare_ics): Likewise.
+ * class.c (build_base_path): Likewise.
+ (resolve_address_of_overloaded_function): Likewise.
+ * cp-tree.h: Likewise.
+ * cvt.c (cp_convert_to_pointer): Likewise.
+ (convert_to_reference): Likewise.
+ (ocp_convert): Likewise.
+ (convert_force): Likewise, tidy.
+ * cxx-pretty-print.c (pp_cxx_postfix_expression): Likewise.
+ (pp_cxx_ptr_operator): Likewise.
+ * decl.c (duplicate_decls): Likewise.
+ (start_decl): Likewise.
+ (grok_op_properties): Likewise.
+ (start_preparsed_function): Likewise.
+ (store_parm_decls): Likewise.
+ (finish_function): Likewise.
+ * decl2.c (delete_sanity): Likewise.
+ (acceptable_java_type): Likewise.
+ (grokbitfield): Likewise.
+ (cp_reconstruct_complex_type): Likewise.
+ * error.c (dump_type_prefix): Likewise.
+ (dump_expr): Likewise.
+ * except.c (push_eh_cleanup): Likewise.
+ (complete_ptr_ref_or_void_ptr_p): Likewise.
+ (can_convert_eh): Likewise.
+ * init.c (build_new_1): Likewise.
+ (build_delete): Likewise.
+ (build_vec_delete): Likewise.
+ * mangle.c (write_type): Likewise.
+ * parser.c (lookup_literal_operator): Likewise.
+ * pt.c (convert_nontype_argument_function): Likewise.
+ (convert_nontype_argument): Likewise.
+ (tsubst): Likewise.
+ (unify): Likewise.
+ (dependent_type_p_r): Likewise.
+ * rtti.c (build_headof): Likewise.
+ (build_typeid): Likewise.
+ (build_dynamic_cast_1): Likewise.
+ (target_incomplete_p): Likewise.
+ (typeinfo_in_lib_p): Likewise.
+ * semantics.c (finish_omp_for): Likewise.
+ (cxx_eval_call_expression): Likewise.
+ (maybe_resolve_dummy): Likewise.
+ * tree.c (build_target_expr): Likewise.
+ (cp_build_qualified_type_real): Likewise.
+ * typeck.c (composite_pointer_type_r): Likewise.
+ (composite_pointer_type): Likewise.
+ (comp_except_types): Likewise.
+ (cxx_sizeof_nowarn): Likewise.
+ (string_conv_p): Likewise.
+ (cp_build_array_ref): Likewise.
+ (cp_build_function_call_vec): Likewise, also use TYPE_PTRFN_P.
+ (pointer_diff): Likewise.
+ (cp_build_addr_expr_1): Likewise.
+ (cp_build_unary_op): Likewise.
+ (build_static_cast_1): Likewise.
+ (cp_build_c_cast): Likewise.
+ (comp_ptr_ttypes_real): Likewise.
+ (ptr_reasonably_similar): Likewise.
+ (comp_ptr_ttypes_const): Likewise.
+ (casts_away_constness): Likewise.
+ (check_literal_operator_args): Likewise.
+ * typeck2.c (build_x_arrow): Likewise.
+ (add_exception_specifier): Likewise.
+
2013-03-29 Jason Merrill <jason@redhat.com>
N3582
T& operator*(T*); */
case INDIRECT_REF:
- if (TREE_CODE (type1) == POINTER_TYPE
+ if (TYPE_PTR_P (type1)
&& !uses_template_parms (TREE_TYPE (type1))
&& (TYPE_PTROB_P (type1)
|| TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
T operator-(T); */
case UNARY_PLUS_EXPR: /* unary + */
- if (TREE_CODE (type1) == POINTER_TYPE)
+ if (TYPE_PTR_P (type1))
break;
case NEGATE_EXPR:
if (ARITHMETIC_TYPE_P (type1))
where CV12 is the union of CV1 and CV2. */
case MEMBER_REF:
- if (TREE_CODE (type1) == POINTER_TYPE
- && TYPE_PTRMEM_P (type2))
+ if (TYPE_PTR_P (type1) && TYPE_PTRMEM_P (type2))
{
tree c1 = TREE_TYPE (type1);
tree c2 = TYPE_PTRMEM_CLASS_TYPE (type2);
|| (TYPE_PTR_P (type1) && TYPE_PTR_P (type2))
|| (TYPE_PTRDATAMEM_P (type1) && TYPE_PTRDATAMEM_P (type2))
|| ((TYPE_PTRMEMFUNC_P (type1)
- || TREE_CODE (type1) == POINTER_TYPE)
+ || TYPE_PTR_P (type1))
&& null_ptr_cst_p (args[1])))
{
type2 = type1;
tree fns = TREE_VALUE (convs);
tree totype = TREE_TYPE (convs);
- if ((TREE_CODE (totype) == POINTER_TYPE
+ if ((TYPE_PTR_P (totype)
&& TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
|| (TREE_CODE (totype) == REFERENCE_TYPE
&& TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
|| (TREE_CODE (totype) == REFERENCE_TYPE
- && TREE_CODE (TREE_TYPE (totype)) == POINTER_TYPE
+ && TYPE_PTR_P (TREE_TYPE (totype))
&& TREE_CODE (TREE_TYPE (TREE_TYPE (totype))) == FUNCTION_TYPE))
for (; fns; fns = OVL_NEXT (fns))
{
So we can assume that anything passed as 'this' is non-null, and
optimize accordingly. */
- gcc_assert (TREE_CODE (parmtype) == POINTER_TYPE);
+ gcc_assert (TYPE_PTR_P (parmtype));
/* Convert to the base in which the function was declared. */
gcc_assert (cand->conversion_path != NULL_TREE);
converted_arg = build_base_path (PLUS_EXPR,
conversion of B* to A* is better than conversion of B* to
void*, and conversion of A* to void* is better than
conversion of B* to void*. */
- if (TREE_CODE (deref_to_type1) == VOID_TYPE
- && TREE_CODE (deref_to_type2) == VOID_TYPE)
+ if (VOID_TYPE_P (deref_to_type1)
+ && VOID_TYPE_P (deref_to_type2))
{
if (is_properly_derived_from (deref_from_type1,
deref_from_type2))
deref_from_type1))
return 1;
}
- else if (TREE_CODE (deref_to_type1) == VOID_TYPE
- || TREE_CODE (deref_to_type2) == VOID_TYPE)
+ else if (VOID_TYPE_P (deref_to_type1)
+ || VOID_TYPE_P (deref_to_type2))
{
if (same_type_p (deref_from_type1, deref_from_type2))
{
- if (TREE_CODE (deref_to_type2) == VOID_TYPE)
+ if (VOID_TYPE_P (deref_to_type2))
{
if (is_properly_derived_from (deref_from_type1,
deref_to_type1))
tree null_test = NULL;
tree ptr_target_type;
int fixed_type_p;
- int want_pointer = TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE;
+ int want_pointer = TYPE_PTR_P (TREE_TYPE (expr));
bool has_empty = false;
bool virtual_access;
/* By the time we get here, we should be seeing only real
pointer-to-member types, not the internal POINTER_TYPE to
METHOD_TYPE representation. */
- gcc_assert (TREE_CODE (target_type) != POINTER_TYPE
+ gcc_assert (!TYPE_PTR_P (target_type)
|| TREE_CODE (TREE_TYPE (target_type)) != METHOD_TYPE);
gcc_assert (is_overloaded_fn (overload));
Keep these checks in ascending order, for speed. */
#define TYPE_OBJ_P(NODE) \
(TREE_CODE (NODE) != REFERENCE_TYPE \
- && TREE_CODE (NODE) != VOID_TYPE \
+ && !VOID_TYPE_P (NODE) \
&& TREE_CODE (NODE) != FUNCTION_TYPE \
&& TREE_CODE (NODE) != METHOD_TYPE)
/* Returns true if NODE is a pointer to function. */
#define TYPE_PTRFN_P(NODE) \
- (TREE_CODE (NODE) == POINTER_TYPE \
+ (TYPE_PTR_P (NODE) \
&& TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
/* Returns true if NODE is a reference to function. */
}
/* Handle anachronistic conversions from (::*)() to cv void* or (*)(). */
- if (TREE_CODE (type) == POINTER_TYPE
+ if (TYPE_PTR_P (type)
&& (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
|| VOID_TYPE_P (TREE_TYPE (type))))
{
if (TYPE_PTRMEMFUNC_P (intype)
|| TREE_CODE (intype) == METHOD_TYPE)
return convert_member_func_to_ptr (type, expr, complain);
- if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
+ if (TYPE_PTR_P (TREE_TYPE (expr)))
return build_nop (type, expr);
intype = TREE_TYPE (expr);
}
intype = TYPE_MAIN_VARIANT (intype);
if (TYPE_MAIN_VARIANT (type) != intype
- && TREE_CODE (type) == POINTER_TYPE
+ && TYPE_PTR_P (type)
&& TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
&& MAYBE_CLASS_TYPE_P (TREE_TYPE (type))
&& MAYBE_CLASS_TYPE_P (TREE_TYPE (intype))
/* B* bp; A& ar = (A&)bp; is valid, but it's probably not what they
meant. */
if ((complain & tf_warning)
- && TREE_CODE (intype) == POINTER_TYPE
+ && TYPE_PTR_P (intype)
&& (comptypes (TREE_TYPE (intype), type,
COMPARE_BASE | COMPARE_DERIVED)))
warning_at (loc, 0, "casting %qT to %qT does not dereference pointer",
if (((INTEGRAL_OR_ENUMERATION_TYPE_P (intype)
|| TREE_CODE (intype) == REAL_TYPE)
&& ! (convtype & CONV_STATIC))
- || TREE_CODE (intype) == POINTER_TYPE)
+ || TYPE_PTR_P (intype))
{
if (complain & tf_error)
permerror (loc, "conversion from %q#T to %q#T", intype, type);
}
if (code == BOOLEAN_TYPE)
{
- if (TREE_CODE (intype) == VOID_TYPE)
+ if (VOID_TYPE_P (intype))
{
if (complain & tf_error)
error_at (loc,
complain));
/* From typeck.c convert_for_assignment */
- if (((TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (e) == ADDR_EXPR
- && TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
+ if (((TYPE_PTR_P (TREE_TYPE (e)) && TREE_CODE (e) == ADDR_EXPR
&& TREE_CODE (TREE_TYPE (TREE_TYPE (e))) == METHOD_TYPE)
|| integer_zerop (e)
|| TYPE_PTRMEMFUNC_P (TREE_TYPE (e)))
if (TREE_CODE (object) == ADDR_EXPR)
object = TREE_OPERAND (object, 0);
- if (TREE_CODE (TREE_TYPE (object)) != POINTER_TYPE)
+ if (!TYPE_PTR_P (TREE_TYPE (object)))
{
pp_cxx_postfix_expression (pp, object);
pp_cxx_dot (pp);
pp_cxx_ptr_operator (pp, TREE_TYPE (t));
pp_c_attributes_display (pp_c_base (pp),
TYPE_ATTRIBUTES (TREE_TYPE (t)));
- if (TREE_CODE (t) == POINTER_TYPE)
+ if (TYPE_PTR_P (t))
{
pp_star (pp);
pp_cxx_cv_qualifier_seq (pp, t);
{
tree t = TREE_VALUE (t1);
- if (TREE_CODE (t) == POINTER_TYPE
+ if (TYPE_PTR_P (t)
&& TYPE_NAME (TREE_TYPE (t))
&& DECL_NAME (TYPE_NAME (TREE_TYPE (t)))
== get_identifier ("FILE")
deprecated_state = DEPRECATED_NORMAL;
- if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE
+ if (decl == NULL_TREE || VOID_TYPE_P (decl)
|| decl == error_mark_node)
return error_mark_node;
if (ref)
t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
- if (TREE_CODE (t) == VOID_TYPE)
+ if (VOID_TYPE_P (t))
warning (OPT_Wconversion,
ref
? G_("conversion to a reference to void "
bool honor_interface;
/* Sanity check. */
- gcc_assert (TREE_CODE (TREE_VALUE (void_list_node)) == VOID_TYPE);
+ gcc_assert (VOID_TYPE_P (TREE_VALUE (void_list_node)));
gcc_assert (TREE_CHAIN (void_list_node) == NULL_TREE);
fntype = TREE_TYPE (decl1);
/* Effective C++ rule 15. */
if (warn_ecpp
&& DECL_OVERLOADED_OPERATOR_P (decl1) == NOP_EXPR
- && TREE_CODE (TREE_TYPE (fntype)) == VOID_TYPE)
+ && VOID_TYPE_P (TREE_TYPE (fntype)))
warning (OPT_Weffc__, "%<operator=%> should return a reference to %<*this%>");
/* Make the init_value nonzero so pushdecl knows this is not tentative.
tree t = DECL_ARGUMENTS (decl1);
gcc_assert (t != NULL_TREE && TREE_CODE (t) == PARM_DECL);
- gcc_assert (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE);
+ gcc_assert (TYPE_PTR_P (TREE_TYPE (t)));
cp_function_chain->x_current_class_ref
= cp_build_indirect_ref (t, RO_NULL, tf_warning_or_error);
if (TREE_CODE (parm) == PARM_DECL)
{
if (DECL_NAME (parm) == NULL_TREE
- || TREE_CODE (parm) != VOID_TYPE)
+ || !VOID_TYPE_P (parm))
pushdecl (parm);
else
error ("parameter %qD declared void", parm);
/* Complain if there's just no return statement. */
if (warn_return_type
- && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
+ && !VOID_TYPE_P (TREE_TYPE (fntype))
&& !dependent_type_p (TREE_TYPE (fntype))
&& !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort or throw. */
}
/* Deleting ptr to void is undefined behavior [expr.delete/3]. */
- if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
+ if (VOID_TYPE_P (TREE_TYPE (type)))
{
warning (0, "deleting %qT is undefined", type);
doing_vec = 0;
if (type == error_mark_node)
return false;
- if (TREE_CODE (type) == VOID_TYPE || TYPE_FOR_JAVA (type))
+ if (VOID_TYPE_P (type) || TYPE_FOR_JAVA (type))
return true;
- if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
+ if (TYPE_PTR_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
{
type = TREE_TYPE (type);
if (TREE_CODE (type) == RECORD_TYPE)
while (--i >= 0)
{
type = TREE_VEC_ELT (args, i);
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
type = TREE_TYPE (type);
if (! TYPE_FOR_JAVA (type))
return false;
return NULL_TREE; /* friends went bad. */
/* Pass friendly classes back. */
- if (TREE_CODE (value) == VOID_TYPE)
+ if (VOID_TYPE_P (value))
return void_type_node;
if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))
{
tree inner, outer;
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
{
inner = cp_reconstruct_complex_type (TREE_TYPE (type), bottom);
outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
pp_c_attributes_display (pp_c_base (cxx_pp),
TYPE_ATTRIBUTES (sub));
}
- if (TREE_CODE (t) == POINTER_TYPE)
+ if (TYPE_PTR_P (t))
pp_character(cxx_pp, '*');
else if (TREE_CODE (t) == REFERENCE_TYPE)
{
{
tree next = TREE_TYPE (TREE_TYPE (t));
- while (TREE_CODE (next) == POINTER_TYPE)
+ while (TYPE_PTR_P (next))
next = TREE_TYPE (next);
if (TREE_CODE (next) == FUNCTION_TYPE)
static bool
decl_is_java_type (tree decl, int err)
{
- bool r = (TREE_CODE (decl) == POINTER_TYPE
+ bool r = (TYPE_PTR_P (decl)
&& TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
&& TYPE_FOR_JAVA (TREE_TYPE (decl)));
return 0;
/* Or a pointer or ref to one, or cv void *. */
- is_ptr = TREE_CODE (type) == POINTER_TYPE;
+ is_ptr = TYPE_PTR_P (type);
if (is_ptr || TREE_CODE (type) == REFERENCE_TYPE)
{
tree core = TREE_TYPE (type);
to = non_reference (to);
from = non_reference (from);
- if (TREE_CODE (to) == POINTER_TYPE && TREE_CODE (from) == POINTER_TYPE)
+ if (TYPE_PTR_P (to) && TYPE_PTR_P (from))
{
to = TREE_TYPE (to);
from = TREE_TYPE (from);
if (! at_least_as_qualified_p (to, from))
return 0;
- if (TREE_CODE (to) == VOID_TYPE)
+ if (VOID_TYPE_P (to))
return 1;
/* Else fall through. */
return error_mark_node;
}
- if (TREE_CODE (elt_type) == VOID_TYPE)
+ if (VOID_TYPE_P (elt_type))
{
if (complain & tf_error)
error ("invalid type %<void%> for new");
this now, since PLACEMENT will change in the calls below. */
placement_first = NULL_TREE;
if (vec_safe_length (*placement) == 1
- && (TREE_CODE (TREE_TYPE ((**placement)[0])) == POINTER_TYPE))
+ && (TYPE_PTR_P (TREE_TYPE ((**placement)[0]))))
placement_first = (**placement)[0];
/* Allocate the object. */
&& TREE_CODE (alloc_call) == CALL_EXPR
&& call_expr_nargs (alloc_call) == 2
&& TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (alloc_call, 0))) == INTEGER_TYPE
- && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (alloc_call, 1))) == POINTER_TYPE)
+ && TYPE_PTR_P (TREE_TYPE (CALL_EXPR_ARG (alloc_call, 1))))
{
tree placement_arg = CALL_EXPR_ARG (alloc_call, 1);
addr = mark_rvalue_use (addr);
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
{
bool complete_p = true;
type = TREE_TYPE (base);
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
{
/* Step back one from start of vector, and read dimension. */
tree cookie_addr;
write_string (target_mangling);
/* Add substitutions for types other than fundamental
types. */
- if (TREE_CODE (type) != VOID_TYPE
+ if (!VOID_TYPE_P (type)
&& TREE_CODE (type) != INTEGER_TYPE
&& TREE_CODE (type) != REAL_TYPE
&& TREE_CODE (type) != BOOLEAN_TYPE)
case POINTER_TYPE:
case REFERENCE_TYPE:
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
write_char ('P');
else if (TYPE_REF_IS_RVALUE (type))
write_char ('O');
{
tree tparm = TREE_VALUE (parmtypes);
tree targ = TREE_TYPE ((*args)[ix]);
- bool ptr = TREE_CODE (tparm) == POINTER_TYPE;
+ bool ptr = TYPE_PTR_P (tparm);
bool arr = TREE_CODE (targ) == ARRAY_TYPE;
if ((ptr || arr || !same_type_p (tparm, targ))
&& (!ptr || !arr
if (TREE_CODE (fn_no_ptr) != FUNCTION_DECL)
{
error ("%qE is not a valid template argument for type %qT", expr, type);
- if (TREE_CODE (type) == POINTER_TYPE)
+ if (TYPE_PTR_P (type))
error ("it must be the address of a function with external linkage");
else
error ("it must be the name of a function with external linkage");
tree addr = TREE_OPERAND (probe, 0);
if (TREE_CODE (probe_type) == REFERENCE_TYPE
&& TREE_CODE (addr) == ADDR_EXPR
- && TREE_CODE (TREE_TYPE (addr)) == POINTER_TYPE
+ && TYPE_PTR_P (TREE_TYPE (addr))
&& (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (probe_type),
TREE_TYPE (TREE_TYPE (addr)))))
tree probe = expr;
STRIP_NOPS (probe);
if (TREE_CODE (probe) == ADDR_EXPR
- && TREE_CODE (TREE_TYPE (probe)) == POINTER_TYPE)
+ && TYPE_PTR_P (TREE_TYPE (probe)))
{
/* Skip the ADDR_EXPR only if it is part of the decay for
an array. Otherwise, it is part of the original argument
only enforce this check in strict C++98 mode. */
if ((TREE_CODE (type) == REFERENCE_TYPE
&& (((cxx_dialect == cxx98) && flag_iso) || code != REFERENCE_TYPE))
- || (code == REFERENCE_TYPE && TREE_CODE (type) == VOID_TYPE))
+ || (code == REFERENCE_TYPE && VOID_TYPE_P (type)))
{
static location_t last_loc;
if (complain & tf_error
&& last_loc != input_location)
{
- if (TREE_CODE (type) == VOID_TYPE)
+ if (VOID_TYPE_P (type))
error ("forming reference to void");
else if (code == POINTER_TYPE)
error ("forming pointer to reference type %qT", type);
error ("creating pointer to member reference type %qT", type);
return error_mark_node;
}
- if (TREE_CODE (type) == VOID_TYPE)
+ if (VOID_TYPE_P (type))
{
if (complain & tf_error)
error ("creating pointer to member of type void");
-- Attempting to create an array with an element type that
is void, a function type, or a reference type, or [DR337]
an abstract class type. */
- if (TREE_CODE (type) == VOID_TYPE
+ if (VOID_TYPE_P (type)
|| TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == REFERENCE_TYPE)
{
case POINTER_TYPE:
{
- if (TREE_CODE (arg) != POINTER_TYPE)
+ if (!TYPE_PTR_P (arg))
return unify_type_mismatch (explain_p, parm, arg);
/* [temp.deduct.call]
return (dependent_type_p (TYPE_PTRMEM_CLASS_TYPE (type))
|| dependent_type_p (TYPE_PTRMEM_POINTED_TO_TYPE
(type)));
- else if (TREE_CODE (type) == POINTER_TYPE
+ else if (TYPE_PTR_P (type)
|| TREE_CODE (type) == REFERENCE_TYPE)
return dependent_type_p (TREE_TYPE (type));
else if (TREE_CODE (type) == FUNCTION_TYPE
tree offset;
tree index;
- gcc_assert (TREE_CODE (type) == POINTER_TYPE);
+ gcc_assert (TYPE_PTR_P (type));
type = TREE_TYPE (type);
if (!TYPE_POLYMORPHIC_P (type))
/* FIXME when integrating with c_fully_fold, mark
resolves_to_fixed_type_p case as a non-constant expression. */
if (INDIRECT_REF_P (exp)
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == POINTER_TYPE
+ && TYPE_PTR_P (TREE_TYPE (TREE_OPERAND (exp, 0)))
&& TYPE_POLYMORPHIC_P (TREE_TYPE (exp))
&& ! resolves_to_fixed_type_p (exp, &nonnull)
&& ! nonnull)
switch (tc)
{
case POINTER_TYPE:
- if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
+ if (VOID_TYPE_P (TREE_TYPE (type)))
break;
/* Fall through. */
case REFERENCE_TYPE:
expr = mark_rvalue_use (expr);
- if (TREE_CODE (exprtype) != POINTER_TYPE)
+ if (!TYPE_PTR_P (exprtype))
{
errstr = _("source is not a pointer");
goto fail;
{
expr = build_base_path (PLUS_EXPR, convert_from_reference (expr),
binfo, 0, complain);
- if (TREE_CODE (exprtype) == POINTER_TYPE)
+ if (TYPE_PTR_P (exprtype))
expr = rvalue (expr);
return expr;
}
return true;
type = TYPE_PTRMEM_POINTED_TO_TYPE (type);
}
- else if (TREE_CODE (type) == POINTER_TYPE)
+ else if (TYPE_PTR_P (type))
type = TREE_TYPE (type);
else
return !COMPLETE_OR_VOID_TYPE_P (type);
{
/* The typeinfo objects for `T*' and `const T*' are in the runtime
library for simple types T. */
- if (TREE_CODE (type) == POINTER_TYPE
+ if (TYPE_PTR_P (type)
&& (cp_type_quals (TREE_TYPE (type)) == TYPE_QUAL_CONST
|| cp_type_quals (TREE_TYPE (type)) == TYPE_UNQUALIFIED))
type = TREE_TYPE (type);
}
if (!INTEGRAL_TYPE_P (TREE_TYPE (decl))
- && TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE)
+ && !TYPE_PTR_P (TREE_TYPE (decl)))
{
error_at (elocus, "invalid type for iteration variable %qE", decl);
return NULL;
{
tree ob_arg = get_nth_callarg (t, 0);
STRIP_NOPS (ob_arg);
- gcc_assert (TREE_CODE (TREE_TYPE (ob_arg)) == POINTER_TYPE
+ gcc_assert (TYPE_PTR_P (TREE_TYPE (ob_arg))
&& CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (ob_arg))));
result = adjust_temp_type (TREE_TYPE (TREE_TYPE (ob_arg)),
result);
return object;
tree type = TYPE_MAIN_VARIANT (TREE_TYPE (object));
- gcc_assert (TREE_CODE (type) != POINTER_TYPE);
+ gcc_assert (!TYPE_PTR_P (type));
if (type != current_class_type
&& current_class_type
gcc_assert (VOID_TYPE_P (TREE_TYPE (value))
|| TREE_TYPE (decl) == TREE_TYPE (value)
/* On ARM ctors return 'this'. */
- || (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
+ || (TYPE_PTR_P (TREE_TYPE (value))
&& TREE_CODE (value) == CALL_EXPR)
|| useless_type_conversion_p (TREE_TYPE (decl),
TREE_TYPE (value)));
pointer-to-member-function type, because these will be distinct
between the unqualified and qualified types. */
if (result != type
- && TREE_CODE (type) == POINTER_TYPE
+ && TYPE_PTR_P (type)
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
&& TYPE_LANG_SPECIFIC (result) == TYPE_LANG_SPECIFIC (type))
TYPE_LANG_SPECIFIC (result) = NULL;
type of a pointer-to-method type, which could have the same
sharing problem described above. */
if (TYPE_CANONICAL (result) != TYPE_CANONICAL (type)
- && TREE_CODE (type) == POINTER_TYPE
+ && TYPE_PTR_P (type)
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
&& (TYPE_LANG_SPECIFIC (TYPE_CANONICAL (result))
== TYPE_LANG_SPECIFIC (TYPE_CANONICAL (type))))
tree attributes;
/* Determine the types pointed to by T1 and T2. */
- if (TREE_CODE (t1) == POINTER_TYPE)
+ if (TYPE_PTR_P (t1))
{
pointee1 = TREE_TYPE (t1);
pointee2 = TREE_TYPE (t2);
types. */
if (same_type_ignoring_top_level_qualifiers_p (pointee1, pointee2))
result_type = pointee1;
- else if ((TREE_CODE (pointee1) == POINTER_TYPE
- && TREE_CODE (pointee2) == POINTER_TYPE)
+ else if ((TYPE_PTR_P (pointee1) && TYPE_PTR_P (pointee2))
|| (TYPE_PTRMEM_P (pointee1) && TYPE_PTRMEM_P (pointee2)))
{
result_type = composite_pointer_type_r (pointee1, pointee2, operation,
and cv2.
If either type is a pointer to void, make sure it is T1. */
- if (TREE_CODE (t2) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (t2)))
+ if (TYPE_PTR_P (t2) && VOID_TYPE_P (TREE_TYPE (t2)))
{
tree t;
t = t1;
}
/* Now, if T1 is a pointer to void, merge the qualifiers. */
- if (TREE_CODE (t1) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (t1)))
+ if (TYPE_PTR_P (t1) && VOID_TYPE_P (TREE_TYPE (t1)))
{
tree attributes;
tree result_type;
return build_type_attribute_variant (result_type, attributes);
}
- if (c_dialect_objc () && TREE_CODE (t1) == POINTER_TYPE
- && TREE_CODE (t2) == POINTER_TYPE)
+ if (c_dialect_objc () && TYPE_PTR_P (t1)
+ && TYPE_PTR_P (t2))
{
if (objc_have_common_type (t1, t2, -3, NULL_TREE))
return objc_common_type (t1, t2);
/* [expr.eq] permits the application of a pointer conversion to
bring the pointers to a common type. */
- if (TREE_CODE (t1) == POINTER_TYPE && TREE_CODE (t2) == POINTER_TYPE
+ if (TYPE_PTR_P (t1) && TYPE_PTR_P (t2)
&& CLASS_TYPE_P (TREE_TYPE (t1))
&& CLASS_TYPE_P (TREE_TYPE (t2))
&& !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (t1),
if (cp_type_quals (a) || cp_type_quals (b))
return false;
- if (TREE_CODE (a) == POINTER_TYPE
- && TREE_CODE (b) == POINTER_TYPE)
+ if (TYPE_PTR_P (a) && TYPE_PTR_P (b))
{
a = TREE_TYPE (a);
b = TREE_TYPE (b);
cxx_sizeof_nowarn (tree type)
{
if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == VOID_TYPE
+ || VOID_TYPE_P (type)
|| TREE_CODE (type) == ERROR_MARK)
return size_one_node;
else if (!COMPLETE_TYPE_P (type))
{
tree t;
- if (TREE_CODE (totype) != POINTER_TYPE)
+ if (!TYPE_PTR_P (totype))
return 0;
t = TREE_TYPE (totype);
if (ar == error_mark_node || ind == error_mark_node)
return error_mark_node;
- if (TREE_CODE (TREE_TYPE (ar)) != POINTER_TYPE)
+ if (!TYPE_PTR_P (TREE_TYPE (ar)))
{
if (complain & tf_error)
error_at (loc, "subscripted value is neither array nor pointer");
return error_mark_node;
}
- is_method = (TREE_CODE (fntype) == POINTER_TYPE
+ is_method = (TYPE_PTR_P (fntype)
&& TREE_CODE (TREE_TYPE (fntype)) == METHOD_TYPE);
- if (!((TREE_CODE (fntype) == POINTER_TYPE
- && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE)
+ if (!(TYPE_PTRFN_P (fntype)
|| is_method
|| TREE_CODE (function) == TEMPLATE_ID_EXPR))
{
if (!complete_type_or_else (target_type, NULL_TREE))
return error_mark_node;
- if (TREE_CODE (target_type) == VOID_TYPE)
+ if (VOID_TYPE_P (target_type))
{
if (complain & tf_error)
permerror (input_location, "ISO C++ forbids using pointer of "
val = build_address (arg);
}
- if (TREE_CODE (argtype) == POINTER_TYPE
+ if (TYPE_PTR_P (argtype)
&& TREE_CODE (TREE_TYPE (argtype)) == METHOD_TYPE)
{
build_ptrmemfunc_type (argtype);
/* Compute the increment. */
- if (TREE_CODE (argtype) == POINTER_TYPE)
+ if (TYPE_PTR_P (argtype))
{
tree type = complete_type (TREE_TYPE (argtype));
/* [expr.static.cast]
Any expression can be explicitly converted to type cv void. */
- if (TREE_CODE (type) == VOID_TYPE)
+ if (VOID_TYPE_P (type))
return convert_to_void (expr, ICV_CAST, complain);
/* [class.abstract]
converted to a pointer to object type. A value of type pointer
to object converted to "pointer to cv void" and back to the
original pointer type will have its original value. */
- if (TREE_CODE (intype) == POINTER_TYPE
+ if (TYPE_PTR_P (intype)
&& VOID_TYPE_P (TREE_TYPE (intype))
&& TYPE_PTROB_P (type))
{
{
/* Allow casting from T1* to T2[] because Cfront allows it.
NIHCL uses it. It is not valid ISO C++ however. */
- if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
+ if (TYPE_PTR_P (TREE_TYPE (expr)))
{
if (complain & tf_error)
permerror (input_location, "ISO C++ forbids casting to an array type %qT", type);
return error_mark_node;
}
- if (TREE_CODE (type) == POINTER_TYPE
+ if (TYPE_PTR_P (type)
&& TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
/* Casting to an integer of smaller size is an error detected elsewhere. */
&& TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (value))
if (TREE_CODE (to) == VECTOR_TYPE)
is_opaque_pointer = vector_targets_convertible_p (to, from);
- if (TREE_CODE (to) != POINTER_TYPE && !TYPE_PTRDATAMEM_P (to))
+ if (!TYPE_PTR_P (to) && !TYPE_PTRDATAMEM_P (to))
return ((constp >= 0 || to_more_cv_qualified)
&& (is_opaque_pointer
|| same_type_ignoring_top_level_qualifiers_p (to, from)));
for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
{
/* Any target type is similar enough to void. */
- if (TREE_CODE (to) == VOID_TYPE)
+ if (VOID_TYPE_P (to))
return !error_type_p (from);
- if (TREE_CODE (from) == VOID_TYPE)
+ if (VOID_TYPE_P (from))
return !error_type_p (to);
if (TREE_CODE (to) != TREE_CODE (from))
if (TREE_CODE (to) == FUNCTION_TYPE)
return !error_type_p (to) && !error_type_p (from);
- if (TREE_CODE (to) != POINTER_TYPE)
+ if (!TYPE_PTR_P (to))
return comptypes
(TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from),
COMPARE_BASE | COMPARE_DERIVED);
if (TREE_CODE (to) == VECTOR_TYPE)
is_opaque_pointer = vector_targets_convertible_p (to, from);
- if (TREE_CODE (to) != POINTER_TYPE)
+ if (!TYPE_PTR_P (to))
return (is_opaque_pointer
|| same_type_ignoring_top_level_qualifiers_p (to, from));
}
/* Casting away constness is only something that makes sense for
pointer or reference types. */
- if (TREE_CODE (t1) != POINTER_TYPE
- || TREE_CODE (t2) != POINTER_TYPE)
+ if (!TYPE_PTR_P (t1) || !TYPE_PTR_P (t2))
return false;
/* Top-level qualifiers don't matter. */
tree t = TREE_VALUE (argtype);
++arity;
- if (TREE_CODE (t) == POINTER_TYPE)
+ if (TYPE_PTR_P (t))
{
bool maybe_raw_p = false;
t = TREE_TYPE (t);
else
last_rval = decay_conversion (expr, complain);
- if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
+ if (TYPE_PTR_P (TREE_TYPE (last_rval)))
{
if (processing_template_decl)
{
/* [except.spec] 1, type in an exception specifier shall not be
incomplete, or pointer or ref to incomplete other than pointer
to cv void. */
- is_ptr = TREE_CODE (core) == POINTER_TYPE;
+ is_ptr = TYPE_PTR_P (core);
if (is_ptr || TREE_CODE (core) == REFERENCE_TYPE)
core = TREE_TYPE (core);
if (complain < 0)