Skip to content

Commit 5c77f91

Browse files
committed
Address review comments
1 parent 612d365 commit 5c77f91

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

clang/lib/AST/Interp/InterpBitcast.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
namespace clang {
1818
namespace interp {
1919

20-
// TODO: Try to e-duplicate the primitive and composite versions.
21-
2220
/// Used to iterate over pointer fields.
2321
using DataFunc =
2422
llvm::function_ref<bool(const Pointer &P, PrimType Ty, size_t BitOffset)>;
@@ -383,7 +381,6 @@ bool DoBitCastToPtr(InterpState &S, const Pointer &P, Pointer &DestPtr,
383381
if (T == PT_Float) {
384382
const QualType FloatType = P.getFieldDesc()->getType();
385383
const auto &Sem = ASTCtx.getFloatTypeSemantics(FloatType);
386-
size_t ValueReprBits = ASTCtx.getTypeSize(FloatType);
387384

388385
CharUnits ObjectReprChars = ASTCtx.getTypeSizeInChars(P.getType());
389386
const std::byte *M = Bytes.getBytes(BitOffset, 1234);

clang/test/AST/Interp/builtin-bit-cast.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ static_assert(FromString == 1633837824); // ref-error {{is not an integral const
4949
// ref-note {{initializer of 'FromString' is not a constant expression}}
5050
#endif
5151

52+
53+
struct S {
54+
int i, j, k;
55+
};
56+
constexpr S func() {
57+
constexpr int array[] = { 12, 42, 128 };
58+
return __builtin_bit_cast(S, array);
59+
}
60+
constexpr S s = func();
61+
static_assert(s.i == 12, "");
62+
static_assert(s.j == 42, "");
63+
static_assert(s.k == 128, "");
64+
5265
template <class Intermediate, class Init>
5366
constexpr bool round_trip(const Init &init) {
5467
return bit_cast<Init>(bit_cast<Intermediate>(init)) == init;

0 commit comments

Comments
 (0)