From e78a21526ffecde620810e9314262808c744e92b Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Tue, 20 Feb 2024 15:42:50 +0200 Subject: [PATCH] Add a test for error estimation for integer LHS in assignment --- test/ErrorEstimation/Assignments.C | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/ErrorEstimation/Assignments.C b/test/ErrorEstimation/Assignments.C index fc257edf4..f809f32b4 100644 --- a/test/ErrorEstimation/Assignments.C +++ b/test/ErrorEstimation/Assignments.C @@ -165,6 +165,27 @@ float func7(float x, float y) { return (x * y); } //CHECK-NEXT: _final_error += std::abs(1. * _ret_value0 * {{.+}}); //CHECK-NEXT: } +float func8(int x, int y) { + x = y * y; + return x; +} + +//CHECK: void func8_grad(int x, int y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { +//CHECK-NEXT: int _t0; +//CHECK-NEXT: _t0 = x; +//CHECK-NEXT: x = y * y; +//CHECK-NEXT: goto _label0; +//CHECK-NEXT: _label0: +//CHECK-NEXT: * _d_x += 1; +//CHECK-NEXT: { +//CHECK-NEXT: x = _t0; +//CHECK-NEXT: int _r_d0 = * _d_x; +//CHECK-NEXT: * _d_x -= _r_d0; +//CHECK-NEXT: * _d_y += _r_d0 * y; +//CHECK-NEXT: * _d_y += y * _r_d0; +//CHECK-NEXT: } +//CHECK-NEXT: } + int main() { clad::estimate_error(func); clad::estimate_error(func2); @@ -173,4 +194,5 @@ int main() { clad::estimate_error(func5); clad::estimate_error(func6); clad::estimate_error(func7); + clad::estimate_error(func8); }