Zebediah Figura (@zfigura) commented about libs/vkd3d-shader/hlsl.c:
{
- struct hlsl_ir_switch_case *c; struct hlsl_ir_switch *s;
- bool has_default = false;
- /* Check for duplicated cases and multiple default statements. */
- LIST_FOR_EACH_ENTRY(c, cases, struct hlsl_ir_switch_case, entry)
- {
if (has_default && c->is_default)
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Found multiple 'default' statements.");
if (hlsl_switch_has_case(c, cases))
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Found duplicate 'case' statement.");
has_default |= c->is_default;
- }
In general we want error reporting to live in the frontend if possible.
INVALID_SYNTAX is also... not what I would use here; I think this may warrant a new error message.
Something nice to have here would be to print the case value itself. Also nice would be to print the location of the previous definition in a hlsl_note().