Skip to content

Commit 3c85102

Browse files
authored
[clang][bytecode] Handle DiscardResult for fixed-point literals (llvm#110475)
1 parent 79382eb commit 3c85102

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ bool Compiler<Emitter>::VisitFixedPointLiteral(const FixedPointLiteral *E) {
763763
assert(E->getType()->isFixedPointType());
764764
assert(classifyPrim(E) == PT_FixedPoint);
765765

766+
if (DiscardResult)
767+
return true;
768+
766769
auto Sem = Ctx.getASTContext().getFixedPointSemantics(E->getType());
767770
APInt Value = E->getValue();
768771
return this->emitConstFixedPoint(FixedPoint(Value, Sem), E);

clang/test/AST/ByteCode/fixed-point.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ static_assert(1.0k != 1.0k); // both-error {{failed due to requirement '1.0k !=
1111
static_assert(1.0k != 1); // both-error {{failed due to requirement '1.0k != 1'}}
1212
static_assert(-12.0k == -(-(-12.0k)));
1313

14+
constexpr _Accum acc = (0.5r, 6.9k);
15+
1416
/// Zero-init.
1517
constexpr _Accum A{};
1618
static_assert(A == 0.0k);

clang/test/Frontend/fixed_point_crash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -verify -ffixed-point %s
2+
// RUN: %clang_cc1 -verify -ffixed-point %s -fexperimental-new-constant-interpreter
23

34
union a {
45
_Accum x;

0 commit comments

Comments
 (0)