mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-21 19:35:36 -05:00
Assorted tweaks to eval_alignment_of.
This commit is contained in:
committed by
Marek Polacek
parent
1cc3dae768
commit
bc94613edd
@@ -3265,32 +3265,32 @@ eval_alignment_of (location_t loc, const constexpr_ctx *ctx, tree r,
|
||||
else if (TREE_CODE (r) == FIELD_DECL
|
||||
|| eval_is_variable (r, kind) == boolean_true_node
|
||||
|| (eval_is_object (kind) == boolean_true_node
|
||||
&& DECL_P (r)
|
||||
&& TREE_CODE (r) != FUNCTION_DECL))
|
||||
return build_int_cst (ret_type, MAX (DECL_ALIGN (r) / BITS_PER_UNIT, 1));
|
||||
&& ((DECL_P (r) && TREE_CODE (r) != FUNCTION_DECL)
|
||||
|| TREE_CODE (r) == COMPONENT_REF)))
|
||||
{
|
||||
if (TREE_CODE (r) == COMPONENT_REF)
|
||||
r = TREE_OPERAND (r, 1);
|
||||
return build_int_cst (ret_type, MAX (DECL_ALIGN_UNIT (r), 1));
|
||||
}
|
||||
else if (TYPE_P (r))
|
||||
type = r;
|
||||
else if (eval_is_object (kind) == boolean_true_node)
|
||||
{
|
||||
if (TREE_CODE (r) == COMPONENT_REF)
|
||||
return build_int_cst (ret_type, MAX (DECL_ALIGN (TREE_OPERAND (r, 1))
|
||||
/ BITS_PER_UNIT, 1));
|
||||
else
|
||||
type = TREE_TYPE (r);
|
||||
}
|
||||
type = TREE_TYPE (r);
|
||||
else
|
||||
gcc_unreachable ();
|
||||
if (TYPE_REF_P (type))
|
||||
type = ptr_type_node;
|
||||
if (!complete_type_or_maybe_complain (type, NULL_TREE, tf_none))
|
||||
return throw_exception (loc, ctx, "reflection with incomplete type",
|
||||
fun, non_constant_p, jump_target);
|
||||
if (FUNC_OR_METHOD_TYPE_P (type))
|
||||
return throw_exception (loc, ctx, "alignment_of on function type",
|
||||
fun, non_constant_p, jump_target);
|
||||
tree ret = c_sizeof_or_alignof_type (loc, type, false, true, 0);
|
||||
if (ret == error_mark_node)
|
||||
return throw_exception (loc, ctx, "reflection with incomplete type",
|
||||
tree ret;
|
||||
if (!complete_type_or_maybe_complain (type, NULL_TREE, tf_none)
|
||||
/* No special casing of references needed, c_sizeof_or_alignof_type
|
||||
returns the same alignment for POINTER_TYPE and REFERENCE_TYPE. */
|
||||
|| ((ret = c_sizeof_or_alignof_type (loc, type, false, true, 0))
|
||||
== error_mark_node))
|
||||
return throw_exception (loc, ctx,
|
||||
"reflection with incomplete type in alignment_of",
|
||||
fun, non_constant_p, jump_target);
|
||||
return fold_convert (ret_type, ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user