summaryrefslogtreecommitdiff
path: root/tests/diagnostics
AgeCommit message (Collapse)Author
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.
2024-05-03Add host shared library target. (#4098)Yong He
* Add host shared library target. * Attempt fix. * Fix warnings. * try fix. * Fix test. * Fix.
2024-04-30Added diagnostics & built-in type lowering for `[CUDAKernel]` functions (#4042)Sai Praveen Bangaru
* Added diagnostics & built-in type lowering for `[CUDAKernel]` functions This PR adds - Diagnostics for non-void return from a cuda kernel entry point - Diagnostics for using differentiable types in a differentiable cuda kernel entry point - Logic for converting built-in types (float3, float3x3, etc..) to portable struct types and unpacks the parameter back into a built-in type on the CUDA side. This is because built-in types have different implementations in CUDA & CPP targets, which causes signature mis-match when linking. * Fix error codes * Add ability to lower structs and arrays that contain built-in types. + Added tests + Fix issue where the host-side was not marshalling data to lowered types. * Update slang-ir-pytorch-cpp-binding.cpp --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-04-23Switch to direct-to-spirv backend as default. (#4002)Yong He
* Switch to direct-to-spirv backend as default. * Fix slang-test. * Fix. * Fix.
2024-04-05Fix __init() functions that returns an existing value (#3866)sriramm-nv
Fixes the issue #3671 * The __init constructors are not expected to return a value like other member functions, but must construct a new value and return the struct type or none. * This patch enables this behavior in the IR lowering without complaining about illegal situations where the user returns an invalid type or none at all. Translate ordinary struct `return ...;` to `this = ...; return this;` Translate NonCopyableType struct `return ...;` to `return this;` * This patch also fixes the issue with type checking when __init() returns a void that mismatches the base type of the struct/ class Translate ordinary struct `return;` to `return this;` Translate NonCopyableType struct `return;` to `return;` * Add end-to-end test and compile only tests to check the above behavior.
2024-04-03Fix assertions due to malformed switch statements (#3858)sriramm-nv
* Fix assertions due to malformed switch statements Fixes the issue #2955 * Checks for multiple case statements with same values * Checks for multiple default cases * Constant-folds case exprs into an Integer value * fix the comments, and updated error code * one-line comment on diagnostic code
2024-04-01Support SM6.6 keyword "WaveSize" (#3871)Jay Kwak
Resolves an issue #3385 Shader Model 6.6 added a new keyowrd, "WaveSize". See the following link for more details: https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_WaveSize.html Co-authored-by: Yong He <yonghe@outlook.com>
2024-04-01Allow bit operators on enum types. (#3862)Yong He
* Allow bit operators on enum types. * Fix.
2024-03-21Support arrow operator `->` on pointers. (#3812)Yong He
2024-03-18Fix SPIRV for mesh shaders, checks for invalid target code&recursion. (#3788)Yong He
* Fix #3780. * Fixers #3781. * Add test for #3781. * Diagnose error on unsupported builtin intrinsic types. * Add check for recursion. * Fix. * Fix. * Fix recursion detection. * Fix. * Fix. * Fix recursion logic. * More fix.
2024-03-14Add diagnostic on invalid type constraint. (#3769)Yong He
2024-03-07Link-time constant and linkage API improvements. (#3708)Yong He
* Link-time constant and linkage API improvements. * Fix. * Allow module name to be empty. * Fix. * Fix. * Fix compile error.
2024-03-05[slangc] generate an error when `-entry` is not specified for targets that ↵Yong He
require them. (#3679) * [slangc] generate an error when `-entry` is not specified for targets that require them. * Fix. * Fix.
2024-03-01Make slangc commandline parsing compatible with renderdoc. (#3658)Yong He
* Make slangc commandline parsing compatible with renderdoc. * Fix tests.
2024-02-26Allow default values for `extern` symbols. (#3632)Yong He
* Allow default values for `extern` symbols. * Fix. * Fix test.
2024-02-20Language server robustness fix. (#3607)Yong He
* Language server robustness fix. * Allow parameter name to be the same as its type. * fix * Fix test.
2024-02-20Support link time type specialization. (#3604)Yong He
2024-02-06Improve Capability System (#3555)Yong He
* Improve capability system. * Update documentation. * Tuning semantics. * LSP: hierarchical diagnostics. * Fix test. * Fix test.
2024-02-02Capability type checking. (#3530)Yong He
* Capability type checking. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2024-02-01Add slangc option to specialize entrypoint + auto glsl mode. (#3531)Yong He
* Add slangc option to specialize entrypoint. * Auto enable glsl mode when input file has glsl extension name. * Fix test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-12-12Define `Texture::Sample` for float element types only. (#3403)Yong He
* Define `Texture::Sample` for float element types only. * Fixes #490. * Fix checking of groupshared. * Add test. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-12-12Add check for invalid use of modifiers. (#3402)Yong He
* Add check for invalid use of modifiers. * Fixes. * Add test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-12-11Diagnose for invalid decl nesting + namespace lookup fixes. (#3397)Yong He
* Diagnose for invalid decl nesting. * Fix. * Fix. * Fix. * Fix `namespace` lookup and `using` resolution. * fix project files. * revert project files. * Enhance namespace syntax, docs. * Fixes. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-12-06Change default visibility of interface members and update docs. (#3381)Yong He
* Update behavior around interfaces and docs. * Update toc --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-12-06Support visibility control and default to `internal`. (#3380)Yong He
* Support visibility control and default to `internal`. * Fix wip. * Fixes. * Fix. * Fix test. * Add legacy language detection and compatibility for existing code. * Add doc. --------- Co-authored-by: Yong He <yhe@nvidia.com>