diff --git a/lib/Differentiator/DiffPlanner.cpp b/lib/Differentiator/DiffPlanner.cpp index 943b1f4e1..28485a413 100644 --- a/lib/Differentiator/DiffPlanner.cpp +++ b/lib/Differentiator/DiffPlanner.cpp @@ -633,9 +633,6 @@ namespace clad { } bool DiffRequest::shouldHaveAdjoint(const VarDecl* VD) const { - if (VD->getType().isConstQualified()) - return false; - if (!EnableVariedAnalysis) return true; diff --git a/test/Gradient/Assignments.C b/test/Gradient/Assignments.C index 023ac8230..3e9ed226b 100644 --- a/test/Gradient/Assignments.C +++ b/test/Gradient/Assignments.C @@ -826,6 +826,7 @@ double constVal(double y, const double x) { } //CHECK: void constVal_grad_0(double y, const double x, double *_d_y) { +//CHECK-NEXT: double _d_z = 0.; //CHECK-NEXT: const double z = y; //CHECK-NEXT: double _t0 = y; //CHECK-NEXT: y *= z; @@ -835,7 +836,9 @@ double constVal(double y, const double x) { //CHECK-NEXT: double _r_d0 = *_d_y; //CHECK-NEXT: *_d_y = 0.; //CHECK-NEXT: *_d_y += _r_d0 * z; +//CHECK-NEXT: _d_z += y * _r_d0; //CHECK-NEXT: } +//CHECK-NEXT: *_d_y += _d_z; //CHECK-NEXT:} double constValInput(const double x) { @@ -916,7 +919,7 @@ int main() { auto const_test = clad::gradient(constVal, "y"); double const_test_result = 0; const_test.execute(3, 4, &const_test_result); - printf("%.2f\n", const_test_result); // CHECK-EXEC: 12.00 + printf("%.2f\n", const_test_result); // CHECK-EXEC: 24.00 auto const_test_input = clad::gradient(constValInput); double const_test_input_result = 0;