[cfe-dev] #define keyword

Eli Friedman eli.friedman at gmail.com
Thu Jun 20 10:01:18 PDT 2013


On Thu, Jun 20, 2013 at 9:53 AM, Seth Cantrell <seth.cantrell at gmail.com>wrote:

> C++11 [macro.names] 17.6.6.3.1 p2 states
>
> > A translation unit shall not #define or #undef names lexically identical
> to keywords, to the identifiers listed in Table 3, or to the
> attribute-tokens described in 7.6.
>
> As I understand it this means a program that does this is ill-formed,
> with a diagnostic required. Clang does not produce any diagnostics for
> such defines/undefs. Am I correct that a diagnostic is required? This
> doesn't sound like it would be too difficult to implement. Is there a
> reason not to have clang produce a warning for this (one that wouldn't
> trigger in system headers)?
>

Given that the requirement is buried in the C++ standard library section,
and there isn't any particular reason to ban #define'ing a keyword for
translation units which don't include the standard library, I would assume
that it's only meant to apply to translation units which include the
standard library.  (I could be wrong, though.)

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130620/b50235a6/attachment.html>


More information about the cfe-dev mailing list