Closed GorNishanov closed 3 years ago
Upon further reflection, the distinction between an attribute applied to the type of the declaration of a particular declaration vs to the declaration ifself can be tackled in the attribute space.
An attribute wrapper TypeAttribute(Attribute) that can be applied to distinguish which of the attributes appertain to the type of the declaration as opposed to the declaration itself.
Therefore, in the example above, IPR representation could be
attributes of declaration of x: [[some-attr1]] [[decl-attr2]] TypeAttribute([[type-attr]])
I think I prefer the latter approach to the one mentioned in the initial post
A few observations:
std::same_as
?As things stand today, reading carefully the current descriptions (including the one quoted above), it sounds like those attributes are supposed to apply to the specific declaration (semantics, not grammar term) obtained from combining a decl-specifier-seq and a particular id-declarator. Consequently, I don't see any additional node or infrastructure needed in IPR to support those curiosities.
However, we do not have a place to put [[type-attr]] which according to the standard
They should go on the particular declaration node they affect.
In IPR, attributes can be applied to statements / declarations.
When translated into an IPR,
declaration of x gets a merged set of attributes [[some-attr1]] [[decl-attr2]] declaration of y gets a merged set of attributes [[some-attr1]] [[decl-attr3]]
However, we do not have a place to put [[type-attr]] which according to the standard:
Possibly some wrapper type, something like
attributed_type(type, attrs)
might be added to handle this. [Edited: Terrible, terrible idea!]