Skip to content

Commit da2f852

Browse files
committed
[AST] Fix certain consteval assignment and comma operator issues with fixed-point types.
Summary: Assignment and comma operators for fixed-point types were being constevaled as other binary operators, but they need special treatment. Reviewers: rjmccall, leonardchan, bjope Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73189
1 parent 474177c commit da2f852

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12920,6 +12920,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
1292012920
}
1292112921

1292212922
bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
12923+
if (E->isPtrMemOp() || E->isAssignmentOp() || E->getOpcode() == BO_Comma)
12924+
return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
12925+
1292312926
const Expr *LHS = E->getLHS();
1292412927
const Expr *RHS = E->getRHS();
1292512928
FixedPointSemantics ResultFXSema =
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -verify -ffixed-point %s
2+
3+
union a {
4+
_Accum x;
5+
int i;
6+
};
7+
8+
int fn1() {
9+
union a m;
10+
m.x = 5.6k;
11+
return m.i;
12+
}
13+
14+
int fn2() {
15+
union a m;
16+
m.x = 7, 5.6k; // expected-warning {{expression result unused}}
17+
return m.x, m.i; // expected-warning {{expression result unused}}
18+
}
19+
20+
_Accum acc = (0.5r, 6.9k); // expected-warning {{expression result unused}}

0 commit comments

Comments
 (0)