Skip to content

Commit fd7a341

Browse files
committed
[Fixed Point] Move the compassign LHS type correction a bit further down. NFCI.
Summary: We can simplify the LHSTy correction for fixed-point compassign by moving it below the point where we know we have a compound assignment. Also, we shouldn't look at the LHS and RHS separately; look at the computation result type instead. Looking at the LHS and RHS is also wrong for compassigns with fixed and floating point (though this does not work upstream yet). Reviewers: leonardchan Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78294
1 parent 485862e commit fd7a341

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13639,14 +13639,6 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
1363913639
if (ResultTy.isNull() || LHS.isInvalid() || RHS.isInvalid())
1364013640
return ExprError();
1364113641

13642-
// The LHS is not converted to the result type for fixed-point compound
13643-
// assignment as the common type is computed on demand. Reset the CompLHSTy
13644-
// to the LHS type we would have gotten after unary conversions.
13645-
if (!CompLHSTy.isNull() &&
13646-
(LHS.get()->getType()->isFixedPointType() ||
13647-
RHS.get()->getType()->isFixedPointType()))
13648-
CompLHSTy = UsualUnaryConversions(LHS.get()).get()->getType();
13649-
1365013642
if (ResultTy->isRealFloatingType() &&
1365113643
(getLangOpts().getFPRoundingMode() != RoundingMode::NearestTiesToEven ||
1365213644
getLangOpts().getFPExceptionMode() != LangOptions::FPE_Ignore))
@@ -13705,6 +13697,12 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
1370513697
OK = LHS.get()->getObjectKind();
1370613698
}
1370713699

13700+
// The LHS is not converted to the result type for fixed-point compound
13701+
// assignment as the common type is computed on demand. Reset the CompLHSTy
13702+
// to the LHS type we would have gotten after unary conversions.
13703+
if (CompResultTy->isFixedPointType())
13704+
CompLHSTy = UsualUnaryConversions(LHS.get()).get()->getType();
13705+
1370813706
if (ConvertHalfVec)
1370913707
return convertHalfVecBinOp(*this, LHS, RHS, Opc, ResultTy, VK, OK, true,
1371013708
OpLoc, CurFPFeatures);

0 commit comments

Comments
 (0)