r224012 - Emit warning if define or undef reserved identifier or keyword.

Aaron Ballman aaron at aaronballman.com
Thu Dec 18 12:01:25 PST 2014


On Wed, Dec 17, 2014 at 7:03 PM, Reid Kleckner <rnk at google.com> wrote:
> On Tue, Dec 16, 2014 at 1:17 PM, Nico Weber <thakis at chromium.org> wrote:
>>
>> Ok, I moved -Wkeyword-macro into -pedantic in r224371. I also removed
>> -Wreserved-id-macro in the same revision, as it's not covered by the
>> standards bit you cited
>
>
> I would like to have something like -Wreserved-id-macro eventually, but it's
> really hard to differentiate between uses of internal C++ implementation
> details (calling __builtin_foo()) and user defined names that are not part
> of "the implementation" (compiler + stdlib). This is partially covered by
> the C++ standard in [global.names]p1:
>
> """
> Certain sets of names and function signatures are always reserved to the
> implementation:
> — Each name that contains a double underscore _ _ or begins with an
> underscore followed by an uppercase
> letter (2.12) is reserved to the implementation for any use.
> — Each name that begins with an underscore is reserved to the implementation
> for use as a name in the
> global namespace.
> """

Uses of reserved names are acceptable and should not be diagnosed.
It's only declarations and definitions of such names that are
problematic.

> It says nothing about macros, though, and this is such a hard problem that
> it's not clear to me that the committed implementation is worth having.

Macro names are names too, as I understand it. ;-) As for the
committed implementation, I think everyone agrees that it requires
further work to be production-ready.

~Aaron




More information about the cfe-commits mailing list