aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2018-05-14 14:55:21 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2018-05-14 14:55:21 +0000
commit9f613f06b0da4b11cde815351df31ad74e22f449 (patch)
treea9943bff782afde1064274c78c9428b0b7aebb43 /gcc/cp/semantics.c
parent403962eac2c99fc7510fbd4164f0a56fb7a15d0c (diff)
downloadgcc-9f613f06b0da4b11cde815351df31ad74e22f449.zip
gcc-9f613f06b0da4b11cde815351df31ad74e22f449.tar.gz
gcc-9f613f06b0da4b11cde815351df31ad74e22f449.tar.bz2
cp-tree.h (TYPE_REF_P): New.
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. From-SVN: r260228
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c71
1 files changed, 34 insertions, 37 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6557817..94e8f54 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1334,7 +1334,7 @@ finish_handler_parms (tree decl, tree handler)
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))
@@ -1835,7 +1835,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
{
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. */
@@ -2729,7 +2729,7 @@ finish_compound_literal (tree type, tree compound_literal,
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,
@@ -4465,7 +4465,7 @@ omp_privatize_field (tree t, bool shared)
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);
@@ -4783,7 +4783,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
}
}
}
- else if (TREE_CODE (type) == POINTER_TYPE)
+ else if (TYPE_PTR_P (type))
{
if (length == NULL_TREE)
{
@@ -4997,7 +4997,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
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)
@@ -5084,7 +5084,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
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),
@@ -5351,7 +5351,7 @@ void
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);
@@ -5402,7 +5402,7 @@ cp_check_omp_declare_reduction (tree 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);
@@ -5511,7 +5511,7 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
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)
{
@@ -5651,8 +5651,7 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
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;
@@ -5770,8 +5769,7 @@ finish_omp_declare_simd_methods (tree t)
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);
@@ -5800,7 +5798,7 @@ cp_finish_omp_clause_depend_sink (tree sink_clause)
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));
@@ -5923,7 +5921,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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",
@@ -5932,12 +5930,12 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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));
@@ -5958,7 +5956,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
&& !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");
@@ -5991,7 +5989,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
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)
{
@@ -6009,7 +6007,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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
@@ -6533,9 +6531,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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))))
@@ -6765,7 +6763,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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))
@@ -6777,8 +6775,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
== 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)))
{
@@ -6845,7 +6842,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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)
@@ -7043,10 +7040,10 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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),
@@ -7287,7 +7284,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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;
}
@@ -7328,7 +7325,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
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);
@@ -8878,7 +8875,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
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))
@@ -9258,14 +9255,14 @@ capture_decltype (tree decl)
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;
@@ -9273,7 +9270,7 @@ capture_decltype (tree decl)
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)
@@ -9363,7 +9360,7 @@ finish_builtin_launder (location_t loc, tree arg, tsubst_flags_t complain)
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;