[PATCH] D144654: [Lex] Warn when defining or undefining any builtin macro

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 10:20:19 PDT 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though precommit CI wasn't able to run on this, so please pay attention to the bots when you land in case there's fallout.



================
Comment at: clang/test/Preprocessor/macro-reserved.cpp:15
 
-#undef __cplusplus
+#undef __cplusplus // expected-warning {{undefining builtin macro}}
 #define __cplusplus
----------------
john.brawn wrote:
> aaron.ballman wrote:
> > Why do we diagnose the undef but not the define?
> After the undef the builtin macro definition no longer exists, so when Preprocessor::HandleDefineDirective checks for an existing definition to see if it's a builtin it doesn't find one.
Ah, that makes sense. Thank you!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144654/new/

https://reviews.llvm.org/D144654



More information about the cfe-commits mailing list