summaryrefslogtreecommitdiff
path: root/tests/diagnostics/constexpr-error.slang
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-09-16 12:51:43 -0700
committerGitHub <noreply@github.com>2025-09-16 19:51:43 +0000
commitafb8146e10626887e3eb9f479480d4f8a1ad6128 (patch)
tree4a11668df1005f4c15e7e25d27615e3116961356 /tests/diagnostics/constexpr-error.slang
parent8ad0ae17880480abe587617c997ab28b23abc146 (diff)
Diagnose error when the function args can't satisfy constexpr parameter requirements (#7269)
## Summary This PR enhances constexpr validation by adding proper error checking when function arguments cannot satisfy constexpr parameter requirements, addressing issue #6370. ## Problem Previously, when a function declared constexpr parameters, the compiler would attempt to propagate constexpr-ness to the call site arguments, but there was insufficient validation and error reporting when this propagation failed. This could lead silent failures where constexpr requirements weren't properly enforced ## Solution This PR adds checks that: 1. **Validates constexpr arguments**: When a function parameter is marked as `constexpr`, the compiler now explicitly checks that the corresponding argument can be marked as `constexpr` 2. **Issues clear compilation errors**: added `Diagnostics::argIsNotConstexpr`) 3. **Handles both call scenarios**: The validation works for both: - Direct function calls with IR-level function definitions - Calls to function from external modules Fixes #6370 --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests/diagnostics/constexpr-error.slang')
-rw-r--r--tests/diagnostics/constexpr-error.slang9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/diagnostics/constexpr-error.slang b/tests/diagnostics/constexpr-error.slang
index 0a4744b71..a79c71847 100644
--- a/tests/diagnostics/constexpr-error.slang
+++ b/tests/diagnostics/constexpr-error.slang
@@ -24,7 +24,7 @@ float4 main() : SV_Target
result += t.Sample(s, uv, int2(0,0));
// Error: data passed through cbuffer isn't compile-time constant
- // CHECK: ([[# @LINE+1]]): error 40006:
+ // CHECK: ([[# @LINE+1]]): error 40012:
result += t.Sample(s, uv, offset);
// Error: data computed via conditional isn't compile-time cosntant
@@ -33,16 +33,19 @@ float4 main() : SV_Target
{
ii = 1;
}
- // CHECK: ([[# @LINE+1]]): error 40006:
+ // CHECK: ([[# @LINE+1]]): error 40012:
result += t.Sample(s, uv, int2(ii));
// Error: data computed in loop isn't compile-time constant
// (and loop isn't unroll-able)
- // CHECK: ([[# @LINE+1]]): error 40006:
+ // CHECK: ([[# @LINE+1]]): error 40012:
for(uint jj = 0; jj < uv.y; jj++)
{
result += t.Sample(s, uv, int2(jj));
}
+
+
+
return result;
} \ No newline at end of file