On Tue, Sep 17, 2024 at 11:13:09AM +0200, Jakub Jelinek wrote:
> So maybe better
> tree arg = e_p->value;
> tree f;
> if ((in_typeof || in_alignof)
> && TREE_CODE (arg) == COMPONENT_REF
> && (f = TREE_OPERAND (arg, 1))
> && TREE_CODE (f) == FIELD_DECL
> && c_flexible_array_member_type_p (TREE_TYPE (f))
> && lookup_attribute ("counted_by", DECL_ATTRIBUTES (f))
> && DECL_NAME (f))
Of course with
{
auto save_in_typeof = in_typeof;
auto save_in_alignof = in_alignof;
in_typeof = 0;
in_alignof = 0;
> arg = build_component_ref (EXPR_LOCATION (arg),
> TREE_OPERAND (arg, 0),
> DECL_NAME (f), UNKNOWN_LOCATION,
> UNKNOWN_LOCATION, true);
in_typeof = save_in_typeof;
in_alignof = save_in_alignof;
}
Why don't we have the sentinel classes C++ FE has in the C FE?
Or outline the counted_by specific part of build_component_ref into
a separate function and call just that.
> if (has_counted_by_object (arg))
> expr.value = get_counted_by_ref (arg);
> else
> expr.value = null_pointer_node;
BTW, concerning just counted_by attribute, how does it play together
with _Atomic on the size member? Perhaps it should be disallowed.
The thing is that _Atomic access lowering is done in the FE, so too
early for tree-object-size, which would either need to reimplement it by
hand (sure, not that difficult, it needs to just atomically load).
Jakub