Skip to content

Commit

Permalink
Don't emit error statements when assigning array sub exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Mar 5, 2024
1 parent 950512b commit de69cd2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Differentiator/ErrorEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,13 @@ void ErrorEstimationHandler::ActBeforeFinalizingVisitCallExpr(
void ErrorEstimationHandler::ActBeforeFinalizingAssignOp(
clang::Expr*& LCloned, clang::Expr*& oldValue,
clang::Expr*& R, clang::BinaryOperator::Opcode& opCode) {
DeclRefExpr* RRef = GetUnderlyingDeclRefOrNull(R);
// In the case that an RHS expression is a declReference, we do not emit
// any error because the assignment operation entials zero error.
// However, for compound assignment operators, the RHS may be a
// declRefExpr but here we will need to emit its error.
// This checks for the above conditions.
if (opCode != BO_Assign || !isa<DeclRefExpr>(R->IgnoreImplicit()))
if (opCode != BO_Assign || !RRef)
EmitBinaryOpErrorStmts(LCloned, oldValue);
}

Expand Down

0 comments on commit de69cd2

Please sign in to comment.