From 92023407b06e48fe03b33fe211d16e493213ca05 Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Mon, 19 Aug 2024 10:36:53 +0300 Subject: [PATCH] WIP --- test/Gradient/Pointers.C | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/Gradient/Pointers.C b/test/Gradient/Pointers.C index 3232bdf42..2db61353a 100644 --- a/test/Gradient/Pointers.C +++ b/test/Gradient/Pointers.C @@ -466,6 +466,21 @@ double cStyleMemoryAlloc(double x, size_t n) { // CHECK-NEXT: free(_d_t); // CHECK-NEXT: } +double* ptrValFn (double* x, int n) { + x += n; + return x; +} + +// CHECK: lksahf + +double nestedPtrFn (double x, double y) { + double arr[] = {x, y}; + double* z = ptrValFn(arr, 1); + return *z; +} + +// CHECK: lksahf + #define NON_MEM_FN_TEST(var)\ res[0]=0;\ var.execute(5,res);\ @@ -573,4 +588,9 @@ int main() { d_x = 0; d_cStyleMemoryAlloc.execute(5, 7, &d_x); printf("%.2f\n", d_x); // CHECK-EXEC: 4.00 + + auto d_nestedPtrFn = clad::gradient(nestedPtrFn); + d_i = 0; d_j = 0; + d_nestedPtrFn.execute(5, 7, &d_i, &d_j); + printf("%.2f %.2f\n", d_i, d_j); // CHECK-EXEC: 7.00 5.00 }