The keywords "true" and "false" shouldn't warn under -Wundef.

llvm-svn: 164279
This commit is contained in:
Eli Friedman 2012-09-20 02:38:38 +00:00
parent fc9420c006
commit 847f3ca350
2 changed files with 4 additions and 1 deletions

View File

@ -178,7 +178,9 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// preprocessor keywords and it wasn't macro expanded, it turns
// into a simple 0, unless it is the C++ keyword "true", in which case it
// turns into "1".
if (ValueLive)
if (ValueLive &&
II->getTokenID() != tok::kw_true &&
II->getTokenID() != tok::kw_false)
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.

View File

@ -1,6 +1,7 @@
/* RUN: %clang_cc1 -E %s -x c++ | grep block_1
RUN: %clang_cc1 -E %s -x c++ | not grep block_2
RUN: %clang_cc1 -E %s -x c | not grep block
RUN: %clang_cc1 -E %s -x c++ -verify -Wundef
*/
#if true