From: Eli Friedman Date: Thu, 20 Sep 2012 02:38:38 +0000 (+0000) Subject: The keywords "true" and "false" shouldn't warn under -Wundef. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c611373cc25300c02043bdde2f2a3d8008704f1;p=clang The keywords "true" and "false" shouldn't warn under -Wundef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164279 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 7cac63eb0f..49dfa198f6 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -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. diff --git a/test/Preprocessor/cxx_true.cpp b/test/Preprocessor/cxx_true.cpp index b123e0cb68..5ee29720d3 100644 --- a/test/Preprocessor/cxx_true.cpp +++ b/test/Preprocessor/cxx_true.cpp @@ -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