[clang-tidy] Reports macro names matching '^_[^A-Z_]' as reserved identifiers #64130
Description
When using the "bugprone-reserved-identifier" plugin (or one of its aliases), clang-tidy reports macro names that start with an underscore and are neither followed by another underscore nor an uppercase letter as being reserved identifiers. I don't know about later versions of the C standard, but it would seem to me that such macro names are neither reserved by ISO/IEC 9899:1999 ("C99") nor ISO/IEC 9899:2011 ("C11") .
The relevant paragraph reads:
All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces. (ISO/IEC 9899:1999, § 7.1.2 (1), my emph.)
However, macros are explicitly "not considered" (para. 1) in § 6.2.1 "Scope of identifiers", where file scope is defined (paras. 2 and 4). They also have a scope of their own, "macro scope" (§ 6.10.3.5). So they seem to not have file scope. And I would argue that § 6.2.1 (1) also excludes them from the definition of "ordinary identifiers" in § 6.2.3 (1). They have a name space of their own (§ 6.10.3 (7)), too. So they don't seem to be in the ordinary name space either. Why should § 7.1.2 (1) apply to them then?
I'm not an expert on C standards, but I'm not alone. Pavel Morozkin agrees in a discussion on reserved identifiers on the GCC issue tracker. And the authors of the CERT C coding standard give various example for identifiers that violate § 7.1.2 (1) of the C standard/rule DCL37 of CERT C, but none that involves a macro name that starts with an underscore and is neither followed by another underscore nor an uppercase letter.
Activity