Skip to content

Commit 6abffad

Browse files
committed
remove using bitwise or for logical or
1 parent 3631e24 commit 6abffad

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

flang/lib/Parser/preprocessor.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,19 +1278,18 @@ static std::int64_t ExpressionValue(const TokenSequence &token,
12781278
case BITAND:
12791279
left = left & right;
12801280
break;
1281-
// (bool)(1 && 2) != (bool)(1 & 2), we can't use bitwise AND here.
1282-
case AND:
1283-
left = left && right;
1284-
break;
12851281
case BITXOR:
12861282
left = left ^ right;
12871283
break;
1288-
// (bool)(1 || 2) == (bool)(1 | 2), seems like we can use `|` here.
1289-
// But should we?
1290-
case OR:
12911284
case BITOR:
12921285
left = left | right;
12931286
break;
1287+
case AND:
1288+
left = left && right;
1289+
break;
1290+
case OR:
1291+
left = left || right;
1292+
break;
12941293
case LT:
12951294
left = -(left < right);
12961295
break;

flang/test/Parser/issue-146362.2.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@ PROGRAM P
77
!CHECK-NOT: FALSE
88
WRITE(*,*) 'FALSE'
99
#endif
10+
#if ((1 || 2) != 3)
11+
!CHECK: TRUE
12+
WRITE(*,*) 'TRUE'
13+
#else
14+
!CHECK-NOT: FALSE
15+
WRITE(*,*) 'FALSE'
16+
#endif
1017
END PROGRAM
1118

0 commit comments

Comments
 (0)