[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
This commit is contained in:
Bevin Hansson 2020-01-22 14:53:11 +01:00
parent 474177c053
commit da2f852e19
2 changed files with 23 additions and 0 deletions

View File

@ -12920,6 +12920,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
}
bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (E->isPtrMemOp() || E->isAssignmentOp() || E->getOpcode() == BO_Comma)
return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
const Expr *LHS = E->getLHS();
const Expr *RHS = E->getRHS();
FixedPointSemantics ResultFXSema =

View File

@ -0,0 +1,20 @@
// RUN: %clang_cc1 -verify -ffixed-point %s
union a {
_Accum x;
int i;
};
int fn1() {
union a m;
m.x = 5.6k;
return m.i;
}
int fn2() {
union a m;
m.x = 7, 5.6k; // expected-warning {{expression result unused}}
return m.x, m.i; // expected-warning {{expression result unused}}
}
_Accum acc = (0.5r, 6.9k); // expected-warning {{expression result unused}}