'true' in a CPP expression evaluates to 1 when in C++ mode. This implements

test/Preprocessor/cxx_true.cpp

llvm-svn: 39399
This commit is contained in:
Chris Lattner 2007-04-10 06:16:30 +00:00
parent 7c718bd5a4
commit a7fa1b247c
2 changed files with 16 additions and 2 deletions

View File

@ -73,9 +73,10 @@ static bool EvaluateValue(APSInt &Result, LexerToken &PeekTok,
// keywords are pp-identifiers, so we can't check the kind.
if (IdentifierInfo *II = PeekTok.getIdentifierInfo()) {
// If this identifier isn't 'defined' and it wasn't macro expanded, it turns
// into a simple 0.
// into a simple 0, unless it is the C++ keyword "true", in which case it
// turns into "1".
if (II->getPPKeywordID() != tok::pp_defined) {
Result = 0;
Result = II->getTokenID() == tok::kw_true;
Result.setIsUnsigned(false); // "0" is signed intmax_t 0.
PP.LexNonComment(PeekTok);
return false;

View File

@ -0,0 +1,13 @@
/* RUN: clang -E t.cpp -x=c++ | grep block_1 &&
RUN: clang -E t.cpp -x=c++ | not grep block_2 &&
RUN: clang -E t.cpp -x=c | not grep block
*/
#if true
block_1
#endif
#if false
block_2
#endif