summaryrefslogtreecommitdiff
path: root/tests/diagnostics
AgeCommit message (Collapse)Author
2025-02-12Fix crash when handling uninitialized resource type (#6338)kaizhangNV
* Fix crash when handling uninitialized resource type close #6328. When declare a var with struct type, if the struct has a resource type field and it doesn't provide explicit constructor, because slang won't implicit construct such variable at declare site if user doesn't explicitly call the initializer list, we should report the resource type field uninitialized as an error to prevent future possible crash when legalize any use of such variable.
2025-02-11Add checking for differentiability of the primal substitute function. (#6277)Sai Praveen Bangaru
Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-05Feature/initialize list side branch (#6058)kaizhangNV
* SP004: implement initialize list translation to ctor - We synthesize a member-wise constructor for each struct follow the rules described in SP004. - Add logic to translate the initialize list to constructor invoke - Add cuda-host decoration for the synthesized constructor - Remove the default constructor when we have a valid member init constructor - Disable -zero-initialize option, will re-implement it in followup (#6109). - Fix the overload lookup issue When creating invoke expression for ctor, we need to call ResolveInvoke() to find us the best candidates, however the existing lookup logic could find us the base constructor for child struct, we should eliminate this case by providing the LookupOptions::IgnoreInheritance to lookup, this requires us to create a subcontext on SemanticsVisitor to indicate that we only want to use this option on looking the constructor. - Do not implicit initialize a struct that doesn't have explicit default constructor. Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-02-04Fix warning about push constants, shaderRecordEXT (#6269)cheneym2
* Fix warning about push constants, shaderRecordEXT These resources should not warn about missing vk::binding. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-01-29Fix combined sampler documentation and warning (#6207)cheneym2
* Fix combined sampler documentation and warning * Update comment, show detailed '-fvk-t-shift' message in warning instead of generic '-fvk-xxx-shift' * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-01-24Add bgra8 format (#6163)Darren Wihandi
* add brga8 format * add tests * minor fixes * cleanup * maybe fix broken quad control test * add missing xslang flag on test --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-24improve error message on generic value decls (#6169)Darren Wihandi
Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-23Fix incorrect resolve of specialization instance (#6162)Jay Kwak
* Fix incorrect resolve of specialization instance While checking the uninitialized variables, we were not resolving the specialized instance correctly. This commit repeats the resolve while the result is a specialization instance. A new test is added for this: tests/diagnostics/uninitialized-generic.slang After the problem is fixed, it revealed another problem in existing tests: tests/compute/nested-generics2.slang tests/diagnostics/uninitialized-local-variables.slang When a struct has a member variable whose type is a generic type, we cannot iterate over its member variables yet, because the type is unknown until the generic function/struct is specialized. We will have to give up checking for these cases.
2025-01-17Refactor _Texture to constrain on texel types. (#6115)Yong He
* Refactor _Texture to constrain on texel types. * Fix tests. * Fix. * Disable glsl texture test because rhi can't run it correctly.
2025-01-15Inline global constants that contains opaque handles for legalization. (#6098)Yong He
* Inline global constants that contains opaque handles for legalization. * Add diagnostics on opaque type global variables. * Fix. * Fix test.
2025-01-14Fix #5354, change diagnostic definition error message and expect output in ↵wij
test (#6067) Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-10Fix potential test failures due to SPIRV validation failure (#6047)Jay Kwak
There are a few tests that are currently passing but could fail when conditions change little bit. When slang-test runs with `test-server`, the spirv validation fails and the test gets reported as failed even though they are actually passing. To avoid the potential problem, this commit adds an empty entry point. Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-07Use disassemble API from SPIRV-Tools (#6001)Jay Kwak
* Use disassemble API from SPIRV-Tools This commit uses C API version of SPIRV disassemble function rather than calling spirv-dis.exe. This allows us to use a correct version of SPIRV disassble function that Slangc.exe is using. The implementation is mostly copied from external/spirv-tools/tools/dis/dis.cpp, which is a source file for building spirv-dis.exe. This commit also includes a fix for a bug in RPC communication to `test-server`. When an RPC connection to `test-server.exe` is reused and the second test abruptly fails due to a compile error or SPIRV validation error, the output from the first test run was incorrectly reused as the output for the second test. This commit resets the RPC result before waiting for the response so that even when the RPC connection is erratically disconnected, the result from the previous run will not be reused incorrectly. Some of the tests appear to be relying on this type of behavior. By using an option, `-skip-spirv-validation`, the RPC connection will continue without an interruption.
2024-12-30Check for undefined %id in spirv_asm block. (#5966)Yong He
2024-12-30Check mismatching method parameter direction against interface declaration. ↵Yong He
(#5964)
2024-12-18Check decl nesting for namespaces. (#5910)Yong He
2024-12-17Add verification logic on push and specialization constants. (#5887)Yong He
* Add verification logic on push and specialization constants. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2024-12-10Enable exprs for GLSL binding layout qualifiers (#5807)Darren
* Allow glsl set and binding layout qualifiers to be compile time integer exprs * add new tests * add comments * cleanup on asserts * addressed review comments and cleanup * fix missing set expr in test * fixed tests and cleanup --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-12-09Report error on nested functions. (#5792)Yong He
* Report error on nested functions. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2024-12-09Fix crash on recursive types. (#5796)Yong He
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2024-12-03Conform non-suffixed integer literals (#5717)Darren Wihandi
* Make non-suffixed integer literal type resolution conform to C * Update integer literal tests * Clean up integer literal implementation a bit * Update docs on integer literals * Clean up docs update * Clean up docs update * Add comment on INT64_MIN edge case * Fixed failing test, fixed formatting and cleaned up code --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-11-22[AD] Add support for resolving custom derivatives where generic parameters ↵Sai Praveen Bangaru
can't be automatically inferred (#5630) * [AD] Add support for resolving custom derivatives where generic parameters can't be automatically inferred * Fix failing tests * Update custom-derivative-generic.slang
2024-11-20Change how DeclRef::toText works (#5592)Sai Praveen Bangaru
* Change how DeclRef::toText works We now ignore the decl-ref heirarchy since that only includes nodes with specialization info & simply walk up the tree of decls, while emitting any specializations present in the decl-ref. * Update some tests. Add cases for direct refs to generic params & Lookup decl refs
2024-10-30Constant-fold for the type-casting in switch-case labels (#5436)Jay Kwak
2024-10-28Replace the word stdlib or standard-library with core-module for source code ↵Jay Kwak
(#5415) This commit changes the word "stdlib" or "standard library" to "core module" in the source code.
2024-10-20Properly check switch case. (#5341)Yong He
2024-09-19Add diagnostic to verify the left hand side of a generic constraint. (#5112)Yong He
* Add diagnostic to verify the left hand side of a generic constraint. * Fix comment.
2024-09-18Lower the priority of looking up the rank of scope (#5065)kaizhangNV
* Lower the priority of looking up the rank of scope In the previous change of #5060, we propose a way to resolve the ambiguous call when considering the scope of a function. But this rule should be considered as a low priority than "specialized candidate", aka. we should consider more "specialized candiate" first. * Count distance between reference site to declaration site Compare the candidate by calculating distance from reference site to declaration site via nearest common prefix in the scope tree. This will involve finding the common parent node of two child nodes and how sum the distance from the common parent to the two child nodes. * Change the priority higher than 'getOverloadRank' * Don't evaluate the scope rank algorithm on generic If the candidate is generic function, the function parameters won't be checked before 'CompareOverloadCandidates', so it will results in that the candidates this function could be invalid. We should not evaluate the distance algorithm in this case, instead we will evaluate later when the candidate is in flavor of Func or Expr since then all the type checks for the function will be done.
2024-09-18Add `IRWArray` interface, and make StructuredBuffer conform to them. (#5097)Yong He
* Add `IRWArray` interface, and make StructuredBuffer conform to them. * Update user guide. * Fix. * Fixes.
2024-09-09Add load paths to return value check (#5042)venkataram-nv
2024-09-05Support entrypoints defined in a namespace. (#5011)Yong He
* Support entrypoints defined in a namespace. * Fix test.
2024-09-04Fix extension override behavior, and disallow extension on interface types. ↵Yong He
(#4977) * Add a test to ensure extension does not override existing conformance. * Fix doc. * Update documentation. * Fix doc. * Add diagnostic test.
2024-08-28Ignoring construct field warnings on delegatory methods (#4911)venkataram-nv
* Ignoring construct field warnings on delegatory methods * Generalizing instruction usage type interface * Skip collection when searching for stores * Adding separate construct delegation tests * Treating differentiable functions as stores
2024-08-16Include inout cast operation as an aliasing instruction (#4859)venkataram-nv
Previously, the warnings were: ``` environment.slang(22): warning 41022: inout parameter 'seed' is never written to public float3 environment_sample(StructuredBuffer <Environment_sample_data> sample_buffer, inout int seed) ^~~~~~~~~~~~~~~~~~ hit.slang(5): warning 41022: inout parameter 'seed' is never written to float3 sample_lights(inout uint seed) ^~~~~~~~~~~~~ ``` With this commit they should not be emitted.
2024-08-14Do not zero-initialize groupshared and rayquery variables (#4838)ArielG-NV
* Do not zero-initialize groupshared and rayquery variables Fixes: #4824 `-zero-initialize` option will explicitly not: 1. Set any groupshared values to defaults 2. Set any rayQuery object to a default state (currently invalid code generation) * grammer * disallow groupshared initializers disallow groupshared initializers & adjust tests accordingly * remove disallowed groupshared-init expression * do not default init if non-copyable --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-08-12Warn when inout parameter is never written (#4777)venkataram-nv
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.
2024-07-31Warnings target switch intrinsic asm (#4727)venkataram-nv
* Proper warning generation for target switches and intrinsic asm * Relaxing terminators * Fix compiler warnings * Rectified target switch reachability check * Simplify target switch reachability check * Refactoring variable names * Using getBlocks * Moving ad hoc special case to diagnostics source * Using the LINE directive for testing * Simplifying reliance on target switches * Skipping IR generation for empty target switches --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-30Fixes for Metal ParameterBlock support. (#4752)Yong He
2024-07-26Disable warnings for input global variables (#4745)venkataram-nv
* Disable warnings for input global variables * Update comment to reflect actual check Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> * Update comments in uninitialized-globals.slang * Update uninitialized-globals.slang * Refactoring test variable * Typo in test --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
2024-07-19Fix the issue of name mangling (#4691)kaizhangNV
* Fix the issue of name mangle During our name mangling, we should add the direction of the parameter in the name, otherwise it could have the name collision which will result in invalid code generation: e.g. // in slang-module.slang export func(float a) { ...} // in test.slang extern func(inout float a); when we compile test.slang, slang will pass a pointer type to the 'func', however, in the slang-module.slang, `func` expects a value instead of pointer. This will lead the wrong spirv code. So we should add the parameter direction into the mangle name such that above two symbols will have the different mangled names, and we will catch this during IR-link stage. * Change to use to get param direction * Address few comments
2024-07-18Warnings for uninitialized fields in constructors (#4680)venkataram-nv
* Detect uninitialized fields in constructors * Reachability check for early returns * Specialized warnings for synthesized default initializers * Handling quirks with constructors * Addressing review comments * Ignore synthesized constructors if they are not used
2024-07-18Fix bug with uninititialized warnings in nested scopes (#4677)venkataram-nv
Previously the warning system ignores undefined variables in nested scopes (blocks in IR).
2024-07-18Add unexpected end of input error to lexer (#4673)Ellie Hermaszewska
* Add unexpected end of input error to lexer * Add end of input test * Simplify testcase
2024-07-16Warnings function parameters (#4626)venkataram-nv
* Handle out/inout functions with separate consideration * Fixing bug with passing aliasable instructions * Handle autodiff functions (fwd and rev) in warning system * Handling interface methods * Handling ref parameters like out/inout * Temporary fix to remaining bugs * Refactoring methods and tests * Recursive check for empty structs * Using default initializable interface in tests * Resolving CI fail
2024-07-09Warnings for uninitialized values (#4530)venkataram-nv
This extends the code for handling uninitialized output parameters. Still needs to handle generic templates and assignment of uninitialized values more carefully. The file containing the relevant code are now in source/slang/slang-ir-use-uninitialized-values.cpp rather than the previous source/slang/slang-ir-use-uninitialized-out-param.h and the top-level function is now checkForUsingUinitializedValues. Additionally a rudimentary test shader has been added for this case, which replaces the old file for out params only; tests/diagnositcs/uninitialized-out.slang becomes tests/diagnositcs/uninitialized.slang. What this does not implement (could be future PRs): * Checking uninitialized fields within constructors * Partially uninitialized values with respect to data structure (e.g. arrays/structs/vector types) * Partially uninitialized values with respect to control flow (e.g. if/else/loop)
2024-06-11Support integer typed textures for GLSL (#4329)Jay Kwak
* Support integer typed textures for GLSL This commit re-enables the ability to sample from an integer typed texture for GLSL functions while keeping it unavailable for HLSL target.
2024-06-11Fix `GetAttributeAtVertex` for spirv and glsl targets. (#4334)Yong He
2024-06-08SPIRV `Block` decoration fixes. (#4303)Yong He
* SPIRV `Block` decoration fixes. - SPIRV does not allow duplicate `Block` decorations. So we shouldn't be generating them. - Also fixes duplication of OpName. - SPIRV and HLSL do not allow ConstantBuffer with trailing unsized arrays. Added a check in the front-end against such code. * Convert failing cross-compile tests to filecheck. --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
2024-06-04Print warning when operator<< shifting too much (#4255)Jay Kwak
* Print warning when operator<< shifting too much Closes #3944 For the given type of the left side operand to `operator<<` is not big enough for the right side operand, print a warning that the result will be always zero.
2024-05-15Add diagnostic to prevent defining unsized variables. (#4168)Yong He
* Add diagnostic to prevent defining unsized static variables. * Fix tests. * Add more tests. * Fix to allow defining variables of link-time size. * update diagnostic message. * Fix tests. * Simplify code.