File tree 2 files changed +14
-7
lines changed
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -1300,12 +1300,12 @@ std::optional<Expr<SomeType>> HollerithToBOZ(FoldingContext &context,
1300
1300
const Expr<SomeType> &expr, const DynamicType &type) {
1301
1301
if (std::optional<std::string> chValue{GetScalarConstantValue<Ascii>(expr)}) {
1302
1302
// Pad on the right with spaces when short, truncate the right if long.
1303
- // TODO: big-endian targets
1304
1303
auto bytes{static_cast <std::size_t >(
1305
1304
ToInt64 (type.MeasureSizeInBytes (context, false )).value ())};
1306
1305
BOZLiteralConstant bits{0 };
1307
1306
for (std::size_t j{0 }; j < bytes; ++j) {
1308
- char ch{j >= chValue->size () ? ' ' : chValue->at (j)};
1307
+ auto idx{isHostLittleEndian ? j : bytes - j - 1 };
1308
+ char ch{idx >= chValue->size () ? ' ' : chValue->at (idx)};
1309
1309
BOZLiteralConstant chBOZ{static_cast <unsigned char >(ch)};
1310
1310
bits = bits.IOR (chBOZ.SHIFTL (8 * j));
1311
1311
}
Original file line number Diff line number Diff line change 1
- ! RUN: %flang_fc1 -fdebug-dump-symbols -pedantic %s 2>&1 | FileCheck %s
1
+ ! RUN: %flang_fc1 -fdebug-dump-symbols -pedantic %s 2>&1 | FileCheck %s \
2
+ ! RUN: --check-prefixes=%if system-aix %{"CHECK","BE"%} \
3
+ ! RUN: %else %{"CHECK","LE"%}
4
+
2
5
! CHECK: DATA statement value initializes 'jx' of type 'INTEGER(4)' with CHARACTER
3
6
! CHECK: DATA statement value initializes 'jy' of type 'INTEGER(4)' with CHARACTER
4
7
! CHECK: DATA statement value initializes 'jz' of type 'INTEGER(4)' with CHARACTER
5
8
! CHECK: DATA statement value initializes 'kx' of type 'INTEGER(8)' with CHARACTER
6
- ! CHECK: jx (InDataStmt) size=4 offset=0: ObjectEntity type: INTEGER(4) init:1684234849_4
7
- ! CHECK: jy (InDataStmt) size=4 offset=4: ObjectEntity type: INTEGER(4) init:543384161_4
8
- ! CHECK: jz (InDataStmt) size=4 offset=8: ObjectEntity type: INTEGER(4) init:1684234849_4
9
- ! CHECK: kx (InDataStmt) size=8 offset=16: ObjectEntity type: INTEGER(8) init:7523094288207667809_8
9
+ ! LE: jx (InDataStmt) size=4 offset=0: ObjectEntity type: INTEGER(4) init:1684234849_4
10
+ ! BE: jx (InDataStmt) size=4 offset=0: ObjectEntity type: INTEGER(4) init:1633837924_4
11
+ ! LE: jy (InDataStmt) size=4 offset=4: ObjectEntity type: INTEGER(4) init:543384161_4
12
+ ! BE: jy (InDataStmt) size=4 offset=4: ObjectEntity type: INTEGER(4) init:1633837856_4
13
+ ! LE: jz (InDataStmt) size=4 offset=8: ObjectEntity type: INTEGER(4) init:1684234849_4
14
+ ! BE: jz (InDataStmt) size=4 offset=8: ObjectEntity type: INTEGER(4) init:1633837924_4
15
+ ! LE: kx (InDataStmt) size=8 offset=16: ObjectEntity type: INTEGER(8) init:7523094288207667809_8
16
+ ! BE: kx (InDataStmt) size=8 offset=16: ObjectEntity type: INTEGER(8) init:7017280452245743464_8
10
17
11
18
integer :: jx, jy, jz
12
19
integer (8 ) :: kx
You can’t perform that action at this time.
0 commit comments