Skip to content

Commit 3631e24

Browse files
committed
initial commit
1 parent 988876c commit 3631e24

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

flang/lib/Parser/preprocessor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,14 +1276,19 @@ static std::int64_t ExpressionValue(const TokenSequence &token,
12761276
left = right >= 64 ? 0 : left >> right;
12771277
break;
12781278
case BITAND:
1279-
case AND:
12801279
left = left & right;
12811280
break;
1281+
// (bool)(1 && 2) != (bool)(1 & 2), we can't use bitwise AND here.
1282+
case AND:
1283+
left = left && right;
1284+
break;
12821285
case BITXOR:
12831286
left = left ^ right;
12841287
break;
1285-
case BITOR:
1288+
// (bool)(1 || 2) == (bool)(1 | 2), seems like we can use `|` here.
1289+
// But should we?
12861290
case OR:
1291+
case BITOR:
12871292
left = left | right;
12881293
break;
12891294
case LT:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!RUN: %flang_fc1 -cpp -fdebug-unparse %s | FileCheck %s
2+
PROGRAM P
3+
#if (1 && 2)
4+
!CHECK: TRUE
5+
WRITE(*,*) 'TRUE'
6+
#else
7+
!CHECK-NOT: FALSE
8+
WRITE(*,*) 'FALSE'
9+
#endif
10+
END PROGRAM
11+

0 commit comments

Comments
 (0)