From b7d318f48db2cb83a41d665f1727ae93fc555124 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 28 Sep 2023 18:07:40 -0700 Subject: Support `constref` parameters passing. (#3249) * Support `constref` parameters passing. * Fix. * Fix. * Add test and diagnostic on mix use of __constref and no_diff. * check for [constref] on differentiable member method. --------- Co-authored-by: Yong He --- .../const-ref-differentiable-param.slang | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/diagnostics/const-ref-differentiable-param.slang (limited to 'tests/diagnostics/const-ref-differentiable-param.slang') diff --git a/tests/diagnostics/const-ref-differentiable-param.slang b/tests/diagnostics/const-ref-differentiable-param.slang new file mode 100644 index 000000000..c345826e7 --- /dev/null +++ b/tests/diagnostics/const-ref-differentiable-param.slang @@ -0,0 +1,38 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + + +[Differentiable] +float f(__constref float3 val) +{ + return val.x; +} + +struct MyType : IDifferentiable +{ + // Error: cannot use constref on a differentiable member method of a differentiable type. + [Differentiable] + [constref] float compute(float x) { return 0; } + + // OK + [Differentiable] + float compute1(float x) { return 0; } + + // OK + [constref] float compute2(float x) { return 0;} +} + +struct MyType2 +{ + // OK. + [Differentiable] + [constref] float compute(float x) { return 0; } + + // OK + [constref] + float compute1(float x) { return 0; } +} + +// CHECK-DAG: {{.*}}(5): error 38034: cannot use '__constref' on a differentiable parameter. +// CHECK-NOT {{.*}}error +// CHECK-DAG: {{.*}}(14): error 38034: cannot use '[constref]' on a differentiable member method of a differentiable type. +// CHECK-NOT {{.*}}error -- cgit v1.2.3