Skip to content
Snippets Groups Projects
Commit 4d2d04e9 authored by Chris Lattner's avatar Chris Lattner
Browse files

fix rdar://6505352 - Bogus warning with -WUndef, a case

Anders noticed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62472 91177308-0d34-0410-b5e6-96231b3b80d8
parent 460b0ac8
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,8 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, ...@@ -91,7 +91,8 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// into a simple 0, unless it is the C++ keyword "true", in which case it // into a simple 0, unless it is the C++ keyword "true", in which case it
// turns into "1". // turns into "1".
if (II->getPPKeywordID() != tok::pp_defined) { 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 = II->getTokenID() == tok::kw_true;
Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0. Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
Result.setRange(PeekTok.getLocation()); Result.setRange(PeekTok.getLocation());
......
/* RUN: clang -E %s -DNO_ERRORS && /* RUN: clang -E %s -DNO_ERRORS -Werror -Wundef &&
RUN: not clang -E %s RUN: not clang -E %s
*/ */
...@@ -44,3 +44,9 @@ baz ...@@ -44,3 +44,9 @@ baz
#endif #endif
// rdar://6505352
// -Wundef should not warn about use of undefined identifier if not live.
#if (!defined(XXX) || XXX > 42)
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment