C++ Logo

sg7

Advanced search

Re: Request for supporting and enumerating user-defined attributes

From: Peter Dimov <pdimov_at_[hidden]>
Date: Mon, 16 Oct 2023 11:20:47 +0300
Iain Sandoe wrote:
> > On 16 Oct 2023, at 08:59, Peter Dimov via SG7 <sg7_at_[hidden]>
> wrote:
> >
> > Ville Voutilainen wrote:
> >> On Mon, 16 Oct 2023 at 10:36, Peter Dimov via SG7
> <sg7_at_[hidden]>
> >> wrote:
> >>> However, the main problem with this is that attributes are currently
> >> ignorable,
> >>> and must remain so. Some implementations such as Clang don't store
> >> unknown
> >>> attributes in the AST at all, so it's not possible to get to them via reflection.
> >>
> >> Surely clang doesn't just toss unknown vendor attributes into the wind?
> >
> > It totally does.
> >
> > https://godbolt.org/z/Gh8681o57
> >
> >> If it does, then perhaps that's a bug to be fixed.
> >
> > The behavior is by design, apparently.
>
> Well, it seems (to me at least), that the purpose of ignorability is to allow a
> compiler
> to drop stuff that it assigns no meaning to, and can make no action on.
>
> It there are attributes that you want preserved, presumably you intend to act
> on
> them - and therefore probably want to make them non-ignored by the
> compiler?

I used to argue that unknown attributes should be retained in the AST for
reflection purposes, but that actually doesn't give us much, so I dropped it.
Annotations work sufficiently differently in that we don't just want the text
of the unknown attribute, we want the compiler to evaluate the constant
expression and to retain its result in the AST, not its text.

Received on 2023-10-16 08:20:51