[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 3 12:27:41 PDT 2024


================
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {
----------------
AaronBallman wrote:

Maybe? I think they absolutely should, but those names are not portable to other compilers.

(FWIW, I like what the C committee did:

6.7.13.1p4:
> In all aspects of the language, a standard attribute specified by this document as an identifier `attr`
and an identifier of the form `__attr__` shall behave the same when used as an attribute token,
except for the spelling.

so standard library vendors can reliably use the underscored names under an existing well-known identifier reservation rule without sacrificing portability.)

https://github.com/llvm/llvm-project/pull/106036


More information about the cfe-commits mailing list