diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-10-29 14:44:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-29 14:44:39 -0700 |
| commit | 725985528f77ba939a5cddc71e5006fee7638465 (patch) | |
| tree | 9b5d4d90a02e38a7c564e6df1fa2944616cf7913 /tests/diagnostics | |
| parent | 56c9de0ae0f0b37d0c5f50f2b39d6c18362642bb (diff) | |
Rework command-line options handling for entry points and targets (#697)
* Rework command-line options handling for entry points and targets
Overview:
* The biggest functionality change is that the implicit ordering constraints when multiple `-entry` options are reversed: any `-stage` option affects the `-entry` to its *left* instead of to its *right* as it used to. This is technically a breaking change, but I expect most users aren't using this feature.
* The options parsing tries to handle profile versions and stages as distinct data (rather than using the combined `Profile` type all over), and treats a `-profile` option that specifies both a profile version and a stage (e.g., `-profile ps_5_0`) as if it were sugar for both a `-profile` and a `-stage` (e.g., `-profile sm_5_0 -stage fragment`).
* We now technically handle multiple `-target` options in one invocation of `-slangc`, but do not advertise that fact in the documentation because it might be confusing for users. Similar to the relationship between `-stage` and `-entry`, any `-profile` option affects the most recent `-target` option unless there is only one `-target`.
* The logic for associating `-o` options with corresponding entry points and targets has been beefed up. The rule is that a `-o` option for a compiled kernel binds to the entry point to its left, unless there is only one entry point (just like for `-stage`). The associated target for a `-o` option is found via a search, however, because otherwise it would be impossible to specify `-o` options for both SPIR-V and DXIL in one pass.
* The handling of output paths for entry points in the internal compiler structures was changed, because previously it could only handle one output path per entry point (even when there are multiple targets). The new logic builds up a per-target mapping from an entry point to its desired output path (if any).
Details:
* Support for formatting profile versions, stages, and compile targets (formats) was added to diagnostic printing, so that we can make better error messages. This is fairly ad hoc, and it would be nice to have all of the string<->enum stuff be more data-driven throughout the codebase.
* Test cases were added for (almost) all of the error conditions in the current options validation. The main one that is missing is around specifying an `-entry` option before any source file when compiling multiple files. This is because the test runner is putting the source file name first on the command line automatically, so we can't reproduce that case.
* Several reflection-related tests now reflect entry points where they didn't before, because the logic for detecting when to infer a default `main` entry point have been made more loose
* On the dxc path, beefed up the handling of mapping from Slang `Profile`s to the coresponding string to use when invoking dxc.
* A bunch of tests cases were in violation of the newly imposed rules, so those needed to be cleaned up.
* There were also a bunch of test cases that had accidentally gotten "disabled" at some point because there were comparing output from `slangc` both with and without a `-pass-through` option, but that meant that any errors in command-line parsing produced the *same* error output in both the Slang and pass-through cases. This change updates `slang-test` to always expect a successful run for these tests, and then manually updates or disables the various test cases that are affected.
* When merging the updated test for matrix layout mode, I found that the new command-line logic was failing to propagate a matrix layout mode passed to `render-test` into the compiler. This was because the `-matrix-layout*` options were implemented as per-target, but the target was being set by API while the option came in via command line (passed through the API). It seems like we want matrix layout mode to be a global option anyway (rather than per-target), so I made that change here.
* Add missing expected output files
* A 64-bit fix
* Remove commented-out code noted in review
Diffstat (limited to 'tests/diagnostics')
49 files changed, 327 insertions, 1 deletions
diff --git a/tests/diagnostics/command-line/duplicate-output.slang b/tests/diagnostics/command-line/duplicate-output.slang new file mode 100644 index 000000000..794a8717b --- /dev/null +++ b/tests/diagnostics/command-line/duplicate-output.slang @@ -0,0 +1,3 @@ +// duplicate-output.slang + +//TEST:SIMPLE:-entry main -stage compute -o myKernel.dxbc -o myKernel.dxbc diff --git a/tests/diagnostics/command-line/duplicate-output.slang.expected b/tests/diagnostics/command-line/duplicate-output.slang.expected new file mode 100644 index 000000000..23e62357f --- /dev/null +++ b/tests/diagnostics/command-line/duplicate-output.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 80: multiple output paths have been specified entry point 'main' on target 'dxbc' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/duplicate-target.slang b/tests/diagnostics/command-line/duplicate-target.slang new file mode 100644 index 000000000..44bbc62c7 --- /dev/null +++ b/tests/diagnostics/command-line/duplicate-target.slang @@ -0,0 +1,3 @@ +// duplicate-target.slang + +//TEST:SIMPLE:-target hlsl -target hlsl diff --git a/tests/diagnostics/command-line/duplicate-target.slang.expected b/tests/diagnostics/command-line/duplicate-target.slang.expected new file mode 100644 index 000000000..4b8a19b2f --- /dev/null +++ b/tests/diagnostics/command-line/duplicate-target.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 50: the target 'hlsl' has been specified more than once +} +standard output = { +} diff --git a/tests/diagnostics/command-line/entry-point-conflicting-stage.slang b/tests/diagnostics/command-line/entry-point-conflicting-stage.slang new file mode 100644 index 000000000..89cf5cba0 --- /dev/null +++ b/tests/diagnostics/command-line/entry-point-conflicting-stage.slang @@ -0,0 +1,5 @@ +// entry-point-conflicting-stage.slang + +//TEST:SIMPLE:-stage vertex -stage fragment + +//TEST:SIMPLE:-entry vsMain -stage compute -stage vertex diff --git a/tests/diagnostics/command-line/entry-point-conflicting-stage.slang.1.expected b/tests/diagnostics/command-line/entry-point-conflicting-stage.slang.1.expected new file mode 100644 index 000000000..2f2e70b4b --- /dev/null +++ b/tests/diagnostics/command-line/entry-point-conflicting-stage.slang.1.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 31: conflicting stages have been specified for entry point 'vsMain' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/entry-point-conflicting-stage.slang.expected b/tests/diagnostics/command-line/entry-point-conflicting-stage.slang.expected new file mode 100644 index 000000000..2b3adab6b --- /dev/null +++ b/tests/diagnostics/command-line/entry-point-conflicting-stage.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 31: conflicting stages have been specified for entry point 'main' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/entry-point-redundant-stage.slang b/tests/diagnostics/command-line/entry-point-redundant-stage.slang new file mode 100644 index 000000000..903d696c7 --- /dev/null +++ b/tests/diagnostics/command-line/entry-point-redundant-stage.slang @@ -0,0 +1,5 @@ +// entry-point-redundant-stage.slang + +//TEST:SIMPLE:-stage vertex -stage vertex + +//TEST:SIMPLE:-entry vsMain -stage vertex -stage vertex diff --git a/tests/diagnostics/command-line/entry-point-redundant-stage.slang.1.expected b/tests/diagnostics/command-line/entry-point-redundant-stage.slang.1.expected new file mode 100644 index 000000000..36674b409 --- /dev/null +++ b/tests/diagnostics/command-line/entry-point-redundant-stage.slang.1.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 30: the stage 'vertex' was specified more than once for entry point 'vsMain' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/entry-point-redundant-stage.slang.expected b/tests/diagnostics/command-line/entry-point-redundant-stage.slang.expected new file mode 100644 index 000000000..e5a66e0fd --- /dev/null +++ b/tests/diagnostics/command-line/entry-point-redundant-stage.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 30: the stage 'vertex' was specified more than once for entry point 'main' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert b/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert new file mode 100644 index 000000000..0ea731470 --- /dev/null +++ b/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert @@ -0,0 +1,3 @@ +// explicit-implicit-stage-mismatch.vert + +//TEST:SIMPLE:-stage fragment diff --git a/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected b/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected new file mode 100644 index 000000000..fef4b78de --- /dev/null +++ b/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected @@ -0,0 +1,7 @@ +result code = -1 +standard error = { +(0): warning 32: the stage specified for entry point 'main' ('pixel') does not match the stage implied by the source file name ('vertex') +(0): error 11: the Slang compiler does not support GLSL as a source language +} +standard output = { +} diff --git a/tests/diagnostics/command-line/option-missing-argument.slang b/tests/diagnostics/command-line/option-missing-argument.slang new file mode 100644 index 000000000..e62b37ba6 --- /dev/null +++ b/tests/diagnostics/command-line/option-missing-argument.slang @@ -0,0 +1,7 @@ +// option-missing-argument.slang + +// Missing argument for an option: + +//TEST:SIMPLE:-target -profile ps_4_0 + +//TEST:SIMPLE:-profile ps_4_0 -target diff --git a/tests/diagnostics/command-line/option-missing-argument.slang.1.expected b/tests/diagnostics/command-line/option-missing-argument.slang.1.expected new file mode 100644 index 000000000..81ab1c485 --- /dev/null +++ b/tests/diagnostics/command-line/option-missing-argument.slang.1.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 21: expected an argument for command-line option '-target' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/option-missing-argument.slang.expected b/tests/diagnostics/command-line/option-missing-argument.slang.expected new file mode 100644 index 000000000..fde023ddd --- /dev/null +++ b/tests/diagnostics/command-line/option-missing-argument.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 13: unknown code generation target '-profile' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/output-no-entry-point.slang b/tests/diagnostics/command-line/output-no-entry-point.slang new file mode 100644 index 000000000..869dcabc4 --- /dev/null +++ b/tests/diagnostics/command-line/output-no-entry-point.slang @@ -0,0 +1,3 @@ +// output-no-entry-point.slang + +//TEST:SIMPLE:-o something.dxbc -entry vsMain -stage vertex -entry fsMain -stage fragment diff --git a/tests/diagnostics/command-line/output-no-entry-point.slang.expected b/tests/diagnostics/command-line/output-no-entry-point.slang.expected new file mode 100644 index 000000000..d04fa06f0 --- /dev/null +++ b/tests/diagnostics/command-line/output-no-entry-point.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 70: the output path 'something.dxbc' is not associated with any entry point; a '-o' option for a compiled kernel must follow the '-entry' option for its corresponding entry point +} +standard output = { +} diff --git a/tests/diagnostics/command-line/output-no-target.slang b/tests/diagnostics/command-line/output-no-target.slang new file mode 100644 index 000000000..32921a8f0 --- /dev/null +++ b/tests/diagnostics/command-line/output-no-target.slang @@ -0,0 +1,3 @@ +// output-no-target.slang + +//TEST:SIMPLE:-target dxbc -target spirv -entry main -stage compute -o bad.hlsl diff --git a/tests/diagnostics/command-line/output-no-target.slang.expected b/tests/diagnostics/command-line/output-no-target.slang.expected new file mode 100644 index 000000000..828c91953 --- /dev/null +++ b/tests/diagnostics/command-line/output-no-target.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 61: no specified '-target' option matches the output path 'bad.hlsl', which implies the 'hlsl' format +} +standard output = { +} diff --git a/tests/diagnostics/command-line/pass-through-no-stage.hlsl b/tests/diagnostics/command-line/pass-through-no-stage.hlsl new file mode 100644 index 000000000..eabdadf10 --- /dev/null +++ b/tests/diagnostics/command-line/pass-through-no-stage.hlsl @@ -0,0 +1,8 @@ +// pass-through-no-stage.hlsl + +// Trying to compile in `-pass-through` mode without +// specifying a stage is an error, because the downstream +// compilers don't support inferring the stage from +// an attribute. + +//TEST:SIMPLE:-pass-through fxc -entry main diff --git a/tests/diagnostics/command-line/pass-through-no-stage.hlsl.expected b/tests/diagnostics/command-line/pass-through-no-stage.hlsl.expected new file mode 100644 index 000000000..87cdbbbb2 --- /dev/null +++ b/tests/diagnostics/command-line/pass-through-no-stage.hlsl.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 35: no stage was specified for entry point 'main'; when using the '-pass-through' option, stages must be fully specified on the command line +} +standard output = { +} diff --git a/tests/diagnostics/command-line/profile-ignored.slang b/tests/diagnostics/command-line/profile-ignored.slang new file mode 100644 index 000000000..8a6590690 --- /dev/null +++ b/tests/diagnostics/command-line/profile-ignored.slang @@ -0,0 +1,14 @@ +// profile-ignored.slang + +// Cases where a `-profile` option gets ignored +// because it doesn't apply to any target + +// Case 1: multiple (conflicting) profiles, so we can't infer a single stage +// +//TEST:SIMPLE:-profile sm_5_0 -profile glsl_450 + + +// Case 2: a `-profile` option before any `-target`, possibly because +// the user is specifying things in the wrong order. +// +//TEST:SIMPLE:-profile sm_5_0 -target dxbc -profile glsl_450 -target spirv diff --git a/tests/diagnostics/command-line/profile-ignored.slang.1.expected b/tests/diagnostics/command-line/profile-ignored.slang.1.expected new file mode 100644 index 000000000..eeaf701c8 --- /dev/null +++ b/tests/diagnostics/command-line/profile-ignored.slang.1.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 43: when using multiple targets, any '-profile' option must follow the '-target' it applies to +} +standard output = { +} diff --git a/tests/diagnostics/command-line/profile-ignored.slang.expected b/tests/diagnostics/command-line/profile-ignored.slang.expected new file mode 100644 index 000000000..f3290a362 --- /dev/null +++ b/tests/diagnostics/command-line/profile-ignored.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 42: a '-profile' option was specified, but no target was specified with '-target' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/stage-ignored.slang b/tests/diagnostics/command-line/stage-ignored.slang new file mode 100644 index 000000000..6d28c52bc --- /dev/null +++ b/tests/diagnostics/command-line/stage-ignored.slang @@ -0,0 +1,9 @@ +// stage-ignored.slang + +// Cases where a `-stage` option gets ignored +// because it doesn't apply to any entry point. + +// A `-stage` option before any `-entry`, possibly because +// the user is specifying things in the wrong order. +// +//TEST:SIMPLE:-stage vertex -entry vsMain -stage fragment -entry psMain diff --git a/tests/diagnostics/command-line/stage-ignored.slang.expected b/tests/diagnostics/command-line/stage-ignored.slang.expected new file mode 100644 index 000000000..725e526fd --- /dev/null +++ b/tests/diagnostics/command-line/stage-ignored.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 34: when compiling multiple entry points, any '-stage' options must follow the '-entry' option that they apply to +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-codegen-target.slang b/tests/diagnostics/command-line/unknown-codegen-target.slang new file mode 100644 index 000000000..57015601d --- /dev/null +++ b/tests/diagnostics/command-line/unknown-codegen-target.slang @@ -0,0 +1,3 @@ +// unknown-codegen-target.slang + +//TEST:SIMPLE:-target z80 diff --git a/tests/diagnostics/command-line/unknown-codegen-target.slang.expected b/tests/diagnostics/command-line/unknown-codegen-target.slang.expected new file mode 100644 index 000000000..0db8d267a --- /dev/null +++ b/tests/diagnostics/command-line/unknown-codegen-target.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 13: unknown code generation target 'z80' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-line-directive-mode.slang b/tests/diagnostics/command-line/unknown-line-directive-mode.slang new file mode 100644 index 000000000..7e61df3f9 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-line-directive-mode.slang @@ -0,0 +1,3 @@ +// unknown-line-directive-mode.slang + +//TEST:SIMPLE:-line-directive-mode quizzical diff --git a/tests/diagnostics/command-line/unknown-line-directive-mode.slang.expected b/tests/diagnostics/command-line/unknown-line-directive-mode.slang.expected new file mode 100644 index 000000000..3451d191b --- /dev/null +++ b/tests/diagnostics/command-line/unknown-line-directive-mode.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 24: unknown '#line' directive mode 'quizzical' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-option.slang b/tests/diagnostics/command-line/unknown-option.slang new file mode 100644 index 000000000..52320d758 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-option.slang @@ -0,0 +1,3 @@ +// unknown-option.slang + +//TEST:SIMPLE:-destroy-all-humans diff --git a/tests/diagnostics/command-line/unknown-option.slang.expected b/tests/diagnostics/command-line/unknown-option.slang.expected new file mode 100644 index 000000000..a74219699 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-option.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 17: unknown command-line option '-destroy-all-humans' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-output-format.slang b/tests/diagnostics/command-line/unknown-output-format.slang new file mode 100644 index 000000000..05f59022b --- /dev/null +++ b/tests/diagnostics/command-line/unknown-output-format.slang @@ -0,0 +1,3 @@ +// unknown-output-format.slang + +//TEST:SIMPLE:-o cookies.jar diff --git a/tests/diagnostics/command-line/unknown-output-format.slang.expected b/tests/diagnostics/command-line/unknown-output-format.slang.expected new file mode 100644 index 000000000..c2f41fa71 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-output-format.slang.expected @@ -0,0 +1,7 @@ +result code = 1 +standard error = { +(0): error 60: cannot infer an output format from the output path 'cookies.jar' +(0): error 70: the output path 'cookies.jar' is not associated with any entry point; a '-o' option for a compiled kernel must follow the '-entry' option for its corresponding entry point +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-pass-through-target.slang b/tests/diagnostics/command-line/unknown-pass-through-target.slang new file mode 100644 index 000000000..7b86f62d6 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-pass-through-target.slang @@ -0,0 +1,3 @@ +// unknown-pass-through-target.slang + +//TEST:SIMPLE:-pass-through subcon diff --git a/tests/diagnostics/command-line/unknown-pass-through-target.slang.expected b/tests/diagnostics/command-line/unknown-pass-through-target.slang.expected new file mode 100644 index 000000000..0c4b1aa4d --- /dev/null +++ b/tests/diagnostics/command-line/unknown-pass-through-target.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 16: unknown pass-through target 'subcon' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-profile.slang b/tests/diagnostics/command-line/unknown-profile.slang new file mode 100644 index 000000000..f96363058 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-profile.slang @@ -0,0 +1,3 @@ +// unknown-profile.slang + +//TEST:SIMPLE:-profile thunder_kiss_65 diff --git a/tests/diagnostics/command-line/unknown-profile.slang.expected b/tests/diagnostics/command-line/unknown-profile.slang.expected new file mode 100644 index 000000000..7e53303fc --- /dev/null +++ b/tests/diagnostics/command-line/unknown-profile.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 14: unknown profile 'thunder_kiss_65' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-source-language.slang b/tests/diagnostics/command-line/unknown-source-language.slang new file mode 100644 index 000000000..c39a3ae4f --- /dev/null +++ b/tests/diagnostics/command-line/unknown-source-language.slang @@ -0,0 +1,5 @@ +// unknown-source-language.slang + +// Unknown source file extension (can't deduce language) + +//TEST:SIMPLE:batmobile.car diff --git a/tests/diagnostics/command-line/unknown-source-language.slang.expected b/tests/diagnostics/command-line/unknown-source-language.slang.expected new file mode 100644 index 000000000..6d596ffab --- /dev/null +++ b/tests/diagnostics/command-line/unknown-source-language.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 12: can't deduce language for input file 'batmobile.car' +} +standard output = { +} diff --git a/tests/diagnostics/command-line/unknown-stage.slang b/tests/diagnostics/command-line/unknown-stage.slang new file mode 100644 index 000000000..1645e5998 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-stage.slang @@ -0,0 +1,3 @@ +// unknown-stage.slang + +//TEST:SIMPLE:-stage green_hills_zone diff --git a/tests/diagnostics/command-line/unknown-stage.slang.expected b/tests/diagnostics/command-line/unknown-stage.slang.expected new file mode 100644 index 000000000..4d00e6ff4 --- /dev/null +++ b/tests/diagnostics/command-line/unknown-stage.slang.expected @@ -0,0 +1,6 @@ +result code = 1 +standard error = { +(0): error 15: unknown stage 'green_hills_zone' +} +standard output = { +} diff --git a/tests/diagnostics/entry-point-no-stage.slang b/tests/diagnostics/entry-point-no-stage.slang new file mode 100644 index 000000000..99ff8193c --- /dev/null +++ b/tests/diagnostics/entry-point-no-stage.slang @@ -0,0 +1,10 @@ +// entry-point-no-stage.slang + +// Confirm that we generate a diagnostic when +// compiling an entry point without any +// stage specified. + +//TEST:SIMPLE:-entry main + +void main() +{} diff --git a/tests/diagnostics/entry-point-no-stage.slang.expected b/tests/diagnostics/entry-point-no-stage.slang.expected new file mode 100644 index 000000000..c63524009 --- /dev/null +++ b/tests/diagnostics/entry-point-no-stage.slang.expected @@ -0,0 +1,6 @@ +result code = -1 +standard error = { +tests/diagnostics/entry-point-no-stage.slang(9): error 38007: no stage specified for entry point 'main'; use either a '[shader("name")]' function attribute or the '-stage <name>' command-line option to specify a stage +} +standard output = { +} diff --git a/tests/diagnostics/entry-point-stage-mismatch.slang b/tests/diagnostics/entry-point-stage-mismatch.slang new file mode 100644 index 000000000..0f143c676 --- /dev/null +++ b/tests/diagnostics/entry-point-stage-mismatch.slang @@ -0,0 +1,10 @@ +// entry-point-stage-mismatch.slang + +// Confirm that we diagnose when stage specified via command +// line doesn't match what was specified via attribute. + +//TEST:SIMPLE:-entry main -stage vertex + +[shader("compute")] +void main() +{} diff --git a/tests/diagnostics/entry-point-stage-mismatch.slang.expected b/tests/diagnostics/entry-point-stage-mismatch.slang.expected new file mode 100644 index 000000000..6a0ebbf96 --- /dev/null +++ b/tests/diagnostics/entry-point-stage-mismatch.slang.expected @@ -0,0 +1,6 @@ +result code = 0 +standard error = { +tests/diagnostics/entry-point-stage-mismatch.slang(9): warning 38006: entry point 'main' being compiled for the 'vertex' stage has a '[shader(...)]' attribute that specifies the 'compute' stage +} +standard output = { +} diff --git a/tests/diagnostics/gh-38-vs.hlsl b/tests/diagnostics/gh-38-vs.hlsl index 7b23efdea..92e0e957e 100644 --- a/tests/diagnostics/gh-38-vs.hlsl +++ b/tests/diagnostics/gh-38-vs.hlsl @@ -1,4 +1,4 @@ -//TEST:SIMPLE: -target dxbc-assembly -profile vs_5_0 -entry main tests/diagnostics/gh-38-fs.hlsl -profile ps_5_0 -entry main +//TEST:SIMPLE: -profile sm_5_0 -entry main -stage vertex tests/diagnostics/gh-38-fs.hlsl -entry main -stage fragment // Ensure that we catch errors with overlapping or conflicting parameter bindings. diff --git a/tests/diagnostics/missing-return.slang b/tests/diagnostics/missing-return.slang new file mode 100644 index 000000000..83f5f9dc1 --- /dev/null +++ b/tests/diagnostics/missing-return.slang @@ -0,0 +1,58 @@ +// missing-return.slang + +//TEST:SIMPLE: + +// Non-`void` function that fails to return + +int bad(int a, int b) +{ + int result = a + b; + + // forgot `return` here +} + +int alsoBad(int a, int b) +{ + if(a > b) + { + return a + b; + } + + // forgot `return` here +} + +int okay(int a, int b) +{ + int tmp = a; + for(;;) + { + if(a > b) + return tmp; + + a = b; + b = tmp; + tmp = a + b; + } + + // Lack of `return` here is not + // a problem, because we can never + // actually get here +} + +int alsoOkay(int a, int b) +{ + int tmp = a; + while(true) + { + if(a > b) + return tmp; + + a = b; + b = tmp; + tmp = a + b; + } + + // Lack of `return` here is not + // a problem, because we can never + // actually get here +}
\ No newline at end of file diff --git a/tests/diagnostics/missing-return.slang.expected b/tests/diagnostics/missing-return.slang.expected new file mode 100644 index 000000000..d44bfc159 --- /dev/null +++ b/tests/diagnostics/missing-return.slang.expected @@ -0,0 +1,7 @@ +result code = 0 +standard error = { +tests/diagnostics/missing-return.slang(7): warning 41010: control flow may reach end of non-'void' function +tests/diagnostics/missing-return.slang(14): warning 41010: control flow may reach end of non-'void' function +} +standard output = { +} |
