[PATCH] D15866: Warn when using `defined` in a macro definition.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 11:41:00 PST 2016


rsmith accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: lib/Lex/PPExpressions.cpp:104-105
@@ +103,4 @@
+  // #else branch.  Emit a warning about this undefined behavior.
+  if (beginLoc.isMacroID())
+    PP.Diag(beginLoc, diag::warn_defined_in_macro);
+
----------------
Move this down to the end of the function, after we've checked that we have a syntactically valid `defined` operator, to avoid duplicate diagnostics on a case like:

  #define FOO defined(
  #if FOO


http://reviews.llvm.org/D15866





More information about the cfe-commits mailing list