diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-07-07 03:52:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-06 15:52:00 -0400 |
| commit | cdfea42f1b28c6ec7b13500a64be823f67bf8e0a (patch) | |
| tree | 4444c21ac369ce8f4c99370fcd47153eeb35581f /tests/diagnostics | |
| parent | 4a88139a86596fd1a546af84ab3210ea3013c58d (diff) | |
Fix erroneous error claiming variable is being used before its declaration (#2958)
* Simplify type of diagnoseImpl
* Show source line for Note diagnostics, opting out of this where appropriate
* Make declared after use diagnostic clearer
* Fix erroneous error claiming variable is being used before its declaration
Closes https://github.com/shader-slang/slang/issues/2936
* Fix build on msvc
---------
Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
Diffstat (limited to 'tests/diagnostics')
13 files changed, 41 insertions, 5 deletions
diff --git a/tests/diagnostics/bad-operator-call.slang.expected b/tests/diagnostics/bad-operator-call.slang.expected index 82eaef848..3abca8f23 100644 --- a/tests/diagnostics/bad-operator-call.slang.expected +++ b/tests/diagnostics/bad-operator-call.slang.expected @@ -22,6 +22,8 @@ core.meta.slang(2425): note 39999: candidate: func +(half, half) -> half core.meta.slang(2417): note 39999: candidate: func +(intptr_t, intptr_t) -> intptr_t core.meta.slang(2409): note 39999: candidate: func +(int64_t, int64_t) -> int64_t tests/diagnostics/bad-operator-call.slang(20): note 39999: 3 more overload candidates + a = a + b; + ^ tests/diagnostics/bad-operator-call.slang(22): error 39999: no overload for '~' applicable to arguments of type (S) a = ~b; ^ @@ -61,6 +63,8 @@ core.meta.slang(2469): note 39999: candidate: func +<3>(uint, uint3) -> uint3 core.meta.slang(2465): note 39999: candidate: func +(uint, uint) -> uint core.meta.slang(2463): note 39999: candidate: func +<4>(uint16_t4, uint16_t) -> uint16_t4 tests/diagnostics/bad-operator-call.slang(33): note 39999: 29 more overload candidates + d = c + d; + ^ } standard output = { } diff --git a/tests/diagnostics/enum-implicit-conversion.slang.expected b/tests/diagnostics/enum-implicit-conversion.slang.expected index 61164bbaa..376dab7e6 100644 --- a/tests/diagnostics/enum-implicit-conversion.slang.expected +++ b/tests/diagnostics/enum-implicit-conversion.slang.expected @@ -16,7 +16,11 @@ tests/diagnostics/enum-implicit-conversion.slang(42): error 39999: ambiguous cal int z = foo(c); ^ tests/diagnostics/enum-implicit-conversion.slang(18): note 39999: candidate: func foo(uint) -> int +int foo(uint x) { return x * 256 * 16; } + ^~~ tests/diagnostics/enum-implicit-conversion.slang(17): note 39999: candidate: func foo(int) -> int +int foo(int x) { return x * 16; } + ^~~ } standard output = { } diff --git a/tests/diagnostics/extension-visibility.slang.expected b/tests/diagnostics/extension-visibility.slang.expected index fb3aaa999..732ff4189 100644 --- a/tests/diagnostics/extension-visibility.slang.expected +++ b/tests/diagnostics/extension-visibility.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/extension-visibility.slang(17): error 39999: could not special return helper(thing); ^ tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of func helper<T>(T) -> int +int helper<T : IThing>(T thing) + ^~~~~~ } standard output = { } diff --git a/tests/diagnostics/generic-type-inference-fail.slang.expected b/tests/diagnostics/generic-type-inference-fail.slang.expected index 3f9753d68..17cb28ca2 100644 --- a/tests/diagnostics/generic-type-inference-fail.slang.expected +++ b/tests/diagnostics/generic-type-inference-fail.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/generic-type-inference-fail.slang(66): error 39999: could not var obj3 = CreateT_Assoc_Inner(1); // ERROR. ^ tests/diagnostics/generic-type-inference-fail.slang(18): note 39999: see declaration of func CreateT_Assoc_Inner<T>(int) -> T.TAssoc +T.TAssoc CreateT_Assoc_Inner<T:IInterface>(int inVal) + ^~~~~~~~~~~~~~~~~~~ } standard output = { } diff --git a/tests/diagnostics/gh-38-vs.hlsl.expected b/tests/diagnostics/gh-38-vs.hlsl.expected index bc33e43aa..30d9516d5 100644 --- a/tests/diagnostics/gh-38-vs.hlsl.expected +++ b/tests/diagnostics/gh-38-vs.hlsl.expected @@ -4,6 +4,8 @@ tests/diagnostics/gh-38-fs.hlsl(5): warning 39001: explicit binding for paramete Texture2D overlappingB : register(t0); ^~~~~~~~~~~~ tests/diagnostics/gh-38-vs.hlsl(5): note: see declaration of 'overlappingA' +Texture2D overlappingA : register(t0); + ^~~~~~~~~~~~ } standard output = { } diff --git a/tests/diagnostics/interface-requirement-not-satisfied.slang.expected b/tests/diagnostics/interface-requirement-not-satisfied.slang.expected index 464ffde25..d9a832794 100644 --- a/tests/diagnostics/interface-requirement-not-satisfied.slang.expected +++ b/tests/diagnostics/interface-requirement-not-satisfied.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/interface-requirement-not-satisfied.slang(10): error 38100: ty struct T : IFoo ^~~~ tests/diagnostics/interface-requirement-not-satisfied.slang(7): note: see declaration of 'bar' + void bar(); + ^~~ } standard output = { } diff --git a/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected b/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected index cc4f310ad..3ac7dfa5f 100644 --- a/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected +++ b/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(10): error struct Counter : IThing ^~~~~~ tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(7): note: see declaration of 'processValue' + int processValue(int inValue); + ^~~~~~~~~~~~ } standard output = { } diff --git a/tests/diagnostics/local-used-before-declared.slang.expected b/tests/diagnostics/local-used-before-declared.slang.expected index 2317c4a67..52a15b7de 100644 --- a/tests/diagnostics/local-used-before-declared.slang.expected +++ b/tests/diagnostics/local-used-before-declared.slang.expected @@ -1,8 +1,8 @@ result code = -1 standard error = { -tests/diagnostics/local-used-before-declared.slang(14): fatal error 39999: local variable 'd' is being used before its declaration. - int d = 0; - ^ +tests/diagnostics/local-used-before-declared.slang(13): error 30015: undefined identifier 'd'. + float c = d + 1.0; + ^ } standard output = { } diff --git a/tests/diagnostics/local-used-in-own-declaration.slang.expected b/tests/diagnostics/local-used-in-own-declaration.slang.expected index 72582e0a9..1517663c0 100644 --- a/tests/diagnostics/local-used-in-own-declaration.slang.expected +++ b/tests/diagnostics/local-used-in-own-declaration.slang.expected @@ -1,8 +1,8 @@ result code = -1 standard error = { -tests/diagnostics/local-used-in-own-declaration.slang(12): fatal error 39999: local variable 'e' is being used before its declaration. +tests/diagnostics/local-used-in-own-declaration.slang(12): error 30015: undefined identifier 'e'. int e = e; - ^ + ^ } standard output = { } diff --git a/tests/diagnostics/overlapping-bindings.slang.expected b/tests/diagnostics/overlapping-bindings.slang.expected index bce542b2b..593f99fb4 100644 --- a/tests/diagnostics/overlapping-bindings.slang.expected +++ b/tests/diagnostics/overlapping-bindings.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/overlapping-bindings.slang(9): warning 39001: explicit binding Texture2D b : register(t0); ^ tests/diagnostics/overlapping-bindings.slang(7): note: see declaration of 'a' +Texture2D a : register(t0); + ^ } standard output = { } diff --git a/tests/diagnostics/parameter-already-defined.slang.expected b/tests/diagnostics/parameter-already-defined.slang.expected index fa9ffb581..42156a020 100644 --- a/tests/diagnostics/parameter-already-defined.slang.expected +++ b/tests/diagnostics/parameter-already-defined.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/parameter-already-defined.slang(4): error 30200: declaration o int foo( int a, float a ) { return 0; } ^ tests/diagnostics/parameter-already-defined.slang(4): note: see previous declaration of 'a' +int foo( int a, float a ) { return 0; } + ^ } standard output = { } diff --git a/tests/diagnostics/single-target-intrinsic.slang.expected b/tests/diagnostics/single-target-intrinsic.slang.expected index d7662c50e..824cd0805 100644 --- a/tests/diagnostics/single-target-intrinsic.slang.expected +++ b/tests/diagnostics/single-target-intrinsic.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/single-target-intrinsic.slang(13): error 30201: function 'doTh T doThing<T>(T in); ^~~~~~~ tests/diagnostics/single-target-intrinsic.slang(10): note: see previous definition of 'doThing' +T doThing<T>(T in); + ^~~~~~~ } standard output = { } diff --git a/tests/diagnostics/variable-redeclaration.slang.expected b/tests/diagnostics/variable-redeclaration.slang.expected index d18e5fb2a..944037b1c 100644 --- a/tests/diagnostics/variable-redeclaration.slang.expected +++ b/tests/diagnostics/variable-redeclaration.slang.expected @@ -4,23 +4,35 @@ tests/diagnostics/variable-redeclaration.slang(14): error 30200: declaration of static Texture2D gA; ^~ tests/diagnostics/variable-redeclaration.slang(12): note: see previous declaration of 'gA' +static int gA; + ^~ tests/diagnostics/variable-redeclaration.slang(44): error 30200: declaration of 'f' conflicts with existing declaration float f; ^ tests/diagnostics/variable-redeclaration.slang(43): note: see previous declaration of 'f' + int f; + ^ tests/diagnostics/variable-redeclaration.slang(51): error 30200: declaration of 'size' conflicts with existing declaration float size) ^~~~ tests/diagnostics/variable-redeclaration.slang(50): note: see previous declaration of 'size' + int size, + ^~~~ tests/diagnostics/variable-redeclaration.slang(21): error 30200: declaration of 'y' conflicts with existing declaration int y = x; ^ tests/diagnostics/variable-redeclaration.slang(20): note: see previous declaration of 'y' + int y = x; + ^ tests/diagnostics/variable-redeclaration.slang(53): error 39999: ambiguous reference to 'size' return size; ^~~~ tests/diagnostics/variable-redeclaration.slang(51): note 39999: candidate: float size + float size) + ^~~~ tests/diagnostics/variable-redeclaration.slang(50): note 39999: candidate: int size + int size, + ^~~~ } standard output = { } |
