Add comments explaining why no special casing of references is needed for *size_of.

This commit is contained in:
Jakub Jelinek
2026-01-07 10:31:56 +01:00
committed by Marek Polacek
parent b8d7f79a11
commit d8e45233dd

View File

@@ -3205,6 +3205,8 @@ eval_size_of (location_t loc, const constexpr_ctx *ctx, tree r,
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);
/* No special casing of references needed, c_sizeof_or_alignof_type returns
the same size for POINTER_TYPE and REFERENCE_TYPE. */
tree ret = c_sizeof_or_alignof_type (loc, type, true, false, 0);
if (ret == error_mark_node)
return throw_exception (loc, ctx, "reflection with incomplete type",
@@ -3345,6 +3347,8 @@ eval_bit_size_of (location_t loc, const constexpr_ctx *ctx, tree r,
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);
/* No special casing of references needed, c_sizeof_or_alignof_type returns
the same size for POINTER_TYPE and REFERENCE_TYPE. */
tree ret = c_sizeof_or_alignof_type (loc, type, true, false, 0);
if (ret == error_mark_node)
return throw_exception (loc, ctx, "reflection with incomplete type",