diff --git a/flang/lib/Evaluate/fold-reduction.h b/flang/lib/Evaluate/fold-reduction.h --- a/flang/lib/Evaluate/fold-reduction.h +++ b/flang/lib/Evaluate/fold-reduction.h @@ -260,12 +260,12 @@ element = prod.value; } }}; + auto result{Expr{DoReduction(*array, dim, identity, accumulator)}}; if (overflow) { context.messages().Say( "PRODUCT() of %s data overflowed"_warn_en_US, T::AsFortran()); - } else { - return Expr{DoReduction(*array, dim, identity, accumulator)}; } + return result; } return Expr{std::move(ref)}; } @@ -301,12 +301,12 @@ element = sum.value; } }}; + auto result{Expr{DoReduction(*array, dim, identity, accumulator)}}; if (overflow) { context.messages().Say( "SUM() of %s data overflowed"_warn_en_US, T::AsFortran()); - } else { - return Expr{DoReduction(*array, dim, identity, accumulator)}; } + return result; } return Expr{std::move(ref)}; }