diff options
| author | Yong He <yonghe@outlook.com> | 2022-08-24 10:56:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 10:56:53 -0700 |
| commit | d245c72f2a92a74ccda83f41758c1948ae5132d3 (patch) | |
| tree | f036e1f2afb7febe2de9b09990bcde6c04f3bad1 /tests | |
| parent | 0b808453407f8feef8574cae99afd90771712185 (diff) | |
Compiler time evaluation of all int and bool operators. (#2376)
* Compiler time evaluation of all int and bool operators.
* Fix linux compile error.
* Fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
4 files changed, 31 insertions, 10 deletions
diff --git a/tests/language-feature/generics/generic-value-constant-folding.slang b/tests/language-feature/generics/generic-value-constant-folding.slang index 1d6781889..f7525e6fd 100644 --- a/tests/language-feature/generics/generic-value-constant-folding.slang +++ b/tests/language-feature/generics/generic-value-constant-folding.slang @@ -1,13 +1,13 @@ //TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type struct PlusOne<let v : int> -{ - static const int value = v + 1; +{ + static const int value = v > 0? v + 1 : v - 1; } struct GetConst<let v : int, let u : int> { - static const int value = (u+v)*(u+v) + PlusOne<u-1>.value; + static const int value = (u/2+v)*(u+v) / PlusOne<u-1>.value; int arr[value]; } @@ -19,7 +19,8 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) { int tid = dispatchThreadID.x; int inVal = tid; - int arr[GetConst<5,2>.value + 1]; - arr[0] = GetConst<5,3>.value + 1; - outputBuffer[tid] = arr[0]; + int arr[GetConst<5, 2>.value + 1]; + GetConst<5, 3> obj; + obj.arr[0] = GetConst<5, 3>.value + 1; + outputBuffer[tid] = obj.arr[0]; } diff --git a/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt b/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt index 2ba17a828..ebb66dc8d 100644 --- a/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt +++ b/tests/language-feature/generics/generic-value-constant-folding.slang.expected.txt @@ -1,5 +1,5 @@ type: int32_t -68 -68 -68 -68 +17 +17 +17 +17
\ No newline at end of file diff --git a/tests/parser/generic-arg.slang b/tests/parser/generic-arg.slang new file mode 100644 index 000000000..6917ad4db --- /dev/null +++ b/tests/parser/generic-arg.slang @@ -0,0 +1,15 @@ +// generic-arg.slang + +//DIAGNOSTIC_TEST:SIMPLE: + +// Test disambiguation of expression and generic app. + +namespace NS +{ + struct MyType<let u : int, let v : int> + { + int arr[u /(v+1-1)]; + } +} + +StructuredBuffer<NS.MyType<1, 3>> buffer; diff --git a/tests/parser/generic-arg.slang.expected b/tests/parser/generic-arg.slang.expected new file mode 100644 index 000000000..4c32e2510 --- /dev/null +++ b/tests/parser/generic-arg.slang.expected @@ -0,0 +1,5 @@ +result code = 0 +standard error = { +} +standard output = { +} |
