On 11/12/23 23:02, Iain Sandoe wrote:
This patch set is not actually particualry new, I have been maintaining
it locally one Darwin branches and it has been tested on several versions
of Darwin both with and without Alex's __has_{feature, extension} patch.
This is one of the three most significant blockers to importing the macOS
SDKs properly, and cannot currently be fixincludes-ed (in fact it can not
ever really since the attribute is uaer-facing and so can be in end-user
code that we cannot fix).
OK for trunk?
thanks
Iain
--- 8< ---
The clang compiler supports essentially arbitrary, per-attribute, syntax and
token forms for attribute arguments. This extends to the case where token
forms are required to be accepted that are not part of the valid set for
standard C or C++.
A motivating example (in the initial attribute of this form implemented
in this patch set) is version-style (i.e. x.y.z) numeric values. At present
the c-family cannot handle this, since invalid numeric tokens are rejected
by both C and C++ frontends before we have a chance to decide to accept them
in custom attribute argument parsing.
The solution proposed in this patch series is to allow for a certain set of
attributes names that are known to be 'clang-form' and to defer argument
token validation until the parse of those arguments.
This does not apparently represent any loss of generality - since the
specific attribute names are already claimed by clang and re-using them with
different semantics in GCC would be a highly unfortunate experience for end-
users.
The first patch here adds a mechanism to check attribute identifiers against
a list known to be in clang form. The 'availability' attribute is added as a
first example.
The acceptance of non-standard tokens is constrained to the interval enclosing
the attribute arguments of cases notified as 'clang-form'.
PR c++/109877
gcc/c-family/ChangeLog:
* c-attribs.cc (attribute_clang_form_p): New.
* c-common.h (attribute_clang_form_p): New.
Patches #1-#3 are fine if nobody has objected within say 48hrs.
Basically I agree that we have to do something along the lines of what
you're suggesting and I just want to give folks the opportunity to raise
any implementation issues they may see.
Patch #4 is obviously darwin specific and I think you can self-approve.
Jeff