forked from OSchip/llvm-project
'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:
parent
7c718bd5a4
commit
a7fa1b247c
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue