From 20bd48659d0009de5477380c335e2419f4c66f8b Mon Sep 17 00:00:00 2001 From: venkataram-nv Date: Mon, 12 Aug 2024 14:18:02 -0700 Subject: Warn when inout parameter is never written (#4777) Addresses #4698 as one approach to diagnose the potential problem. Emit warnings when a user marks a parameter as `inout` but never writes to it in the function. A new intrinsic function `unmodified(out T)` has been added to explicitly indicate that an `inout` variable will not be modified in the function. This is only one way to address the specific validation error in #4698. In general it seems that DXC does some more extensive checks on actual struct fields (as opposed to observing arbitrary struct writes), so that will be the next step. --- tests/language-feature/unsized-array.slang | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/language-feature/unsized-array.slang') diff --git a/tests/language-feature/unsized-array.slang b/tests/language-feature/unsized-array.slang index c4479867e..19ab0bd63 100644 --- a/tests/language-feature/unsized-array.slang +++ b/tests/language-feature/unsized-array.slang @@ -17,6 +17,7 @@ int test(int arr[]) int test2(inout T arr[]) { + unmodified(arr); return arr.getCount(); } -- cgit v1.2.3