diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-01-18 19:46:00 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-01-18 19:46:00 +0000 |
commit | 3748d41833787fcbf59cc5624e8d2b042a8991bc (patch) | |
tree | f3fcdba7decca7ee845a1bb3f885cb0baa1b4d83 /lib/AST/ExprConstant.cpp | |
parent | 55c8788102d8fd203270fabd6513247b2d7fbd87 (diff) | |
parent | e054eb577a1f469b1a4a49fce08572c76e2dddf2 (diff) |
Creating branches/google/stable and tags/google/stable/2019-01-18 from r351319
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@351578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 837dc9c2a8..da093ff22c 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -3439,19 +3439,31 @@ struct CompoundAssignSubobjectHandler { if (!checkConst(SubobjType)) return false; - if (!SubobjType->isIntegerType() || !RHS.isInt()) { + if (!SubobjType->isIntegerType()) { // We don't support compound assignment on integer-cast-to-pointer // values. Info.FFDiag(E); return false; } - APSInt LHS = HandleIntToIntCast(Info, E, PromotedLHSType, - SubobjType, Value); - if (!handleIntIntBinOp(Info, E, LHS, Opcode, RHS.getInt(), LHS)) - return false; - Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS); - return true; + if (RHS.isInt()) { + APSInt LHS = + HandleIntToIntCast(Info, E, PromotedLHSType, SubobjType, Value); + if (!handleIntIntBinOp(Info, E, LHS, Opcode, RHS.getInt(), LHS)) + return false; + Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS); + return true; + } else if (RHS.isFloat()) { + APFloat FValue(0.0); + return HandleIntToFloatCast(Info, E, SubobjType, Value, PromotedLHSType, + FValue) && + handleFloatFloatBinOp(Info, E, FValue, Opcode, RHS.getFloat()) && + HandleFloatToIntCast(Info, E, PromotedLHSType, FValue, SubobjType, + Value); + } + + Info.FFDiag(E); + return false; } bool found(APFloat &Value, QualType SubobjType) { return checkConst(SubobjType) && @@ -4450,7 +4462,7 @@ static bool HandleFunctionCall(SourceLocation CallLoc, if (!handleLValueToRValueConversion(Info, Args[0], Args[0]->getType(), RHS, RHSValue)) return false; - if (!handleAssignment(Info, Args[0], *This, MD->getThisType(Info.Ctx), + if (!handleAssignment(Info, Args[0], *This, MD->getThisType(), RHSValue)) return false; This->moveInto(Result); |