[cfe-commits] r62472 - in /cfe/trunk: lib/Lex/PPExpressions.cpp test/Preprocessor/expr_liveness.c

Chris Lattner sabre at nondot.org
Sun Jan 18 13:18:58 PST 2009


Author: lattner
Date: Sun Jan 18 15:18:58 2009
New Revision: 62472

URL: http://llvm.org/viewvc/llvm-project?rev=62472&view=rev
Log:
fix rdar://6505352 - Bogus warning with -WUndef, a case
Anders noticed.

Modified:
    cfe/trunk/lib/Lex/PPExpressions.cpp
    cfe/trunk/test/Preprocessor/expr_liveness.c

Modified: cfe/trunk/lib/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=62472&r1=62471&r2=62472&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/lib/Lex/PPExpressions.cpp Sun Jan 18 15:18:58 2009
@@ -91,7 +91,8 @@
     // into a simple 0, unless it is the C++ keyword "true", in which case it
     // turns into "1".
     if (II->getPPKeywordID() != tok::pp_defined) {
-      PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+      if (ValueLive)
+        PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
       Result.Val = II->getTokenID() == tok::kw_true;
       Result.Val.setIsUnsigned(false);  // "0" is signed intmax_t 0.
       Result.setRange(PeekTok.getLocation());

Modified: cfe/trunk/test/Preprocessor/expr_liveness.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/expr_liveness.c?rev=62472&r1=62471&r2=62472&view=diff

==============================================================================
--- cfe/trunk/test/Preprocessor/expr_liveness.c (original)
+++ cfe/trunk/test/Preprocessor/expr_liveness.c Sun Jan 18 15:18:58 2009
@@ -1,4 +1,4 @@
-/* RUN: clang -E %s -DNO_ERRORS &&
+/* RUN: clang -E %s -DNO_ERRORS -Werror -Wundef &&
    RUN: not clang -E %s
  */
 
@@ -44,3 +44,9 @@
 
 
 #endif
+
+// rdar://6505352
+// -Wundef should not warn about use of undefined identifier if not live.
+#if (!defined(XXX) || XXX > 42)
+#endif
+





More information about the cfe-commits mailing list