<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64130>64130</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Reports macro names matching '^_[^A-Z_]' as reserved identifiers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          odkr
      </td>
    </tr>
</table>

<pre>
    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](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51437#c16). 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](https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier) 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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVk1v4zYQ_TX0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