From: Zebediah Figura zfigura@codeweavers.com
Avoid letting them fall through to the default rule.
A syntax error will be emitted by the parser. --- libs/vkd3d-shader/preproc.l | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 7686e0187..be4a05989 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -175,9 +175,9 @@ INT_SUFFIX [uUlL]{0,2} return T_NEWLINE; }
-<INITIAL>{WS}+ {} +<INITIAL,INCLUDE,LINE>{WS}+ {} <INITIAL>[-()[]{},+!*/<>&|^?:] {return yytext[0];} -<INITIAL>. {return T_TEXT;} +<INITIAL,INCLUDE,LINE>. {return T_TEXT;}
%%
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/preproc.l | 1 + 1 file changed, 1 insertion(+)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index be4a05989..fc40ce7b8 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -40,6 +40,7 @@ static void update_location(struct preproc_ctx *ctx); %option bison-locations %option extra-type="struct preproc_ctx *" %option never-interactive +%option nodefault %option noinput %option nounput %option noyy_top_state
From: Zebediah Figura zfigura@codeweavers.com
Avoid letting them fall through to the default rule. --- libs/vkd3d-shader/hlsl.l | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 10751bbe9..8a7cd2343 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -266,6 +266,10 @@ row_major {return KW_ROW_MAJOR; } return STRING; } <pp_line>{WS}+ {} +<pp_line>{ANY} { + FIXME("Malformed preprocessor line directive?\n"); + BEGIN(INITIAL); + } <pp_line>{NEWLINE} { FIXME("Malformed preprocessor line directive?\n"); BEGIN(INITIAL);
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.l | 1 + 1 file changed, 1 insertion(+)
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index 8a7cd2343..6c2324c7b 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -37,6 +37,7 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc); %option bison-locations %option extra-type="struct hlsl_ctx *" %option never-interactive +%option nodefault %option noinput %option nounput %option noyywrap
From: Zebediah Figura zfigura@codeweavers.com
This makes it easier to catch when new enum cases are added. --- libs/vkd3d-shader/d3dbc.c | 4 +--- libs/vkd3d-shader/hlsl.c | 11 ++++------- libs/vkd3d-shader/hlsl.y | 7 +++++-- libs/vkd3d-shader/tpf.c | 24 +++++++++++++----------- 4 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index 823df6f62..39fbac9c5 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1131,10 +1131,8 @@ static D3DXPARAMETER_CLASS sm1_class(const struct hlsl_type *type) return D3DXPC_STRUCT; case HLSL_CLASS_VECTOR: return D3DXPC_VECTOR; - default: - ERR("Invalid class %#x.\n", type->class); - vkd3d_unreachable(); } + vkd3d_unreachable(); }
static D3DXPARAMETER_TYPE sm1_base_type(const struct hlsl_type *type) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 9de37a93c..63866534a 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -773,10 +773,9 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type)
case HLSL_CLASS_OBJECT: return 1; - - default: - vkd3d_unreachable(); } + + vkd3d_unreachable(); }
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2) @@ -2016,11 +2015,9 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru return string; } } - - default: - vkd3d_string_buffer_printf(string, "<unexpected type>"); - return string; } + + vkd3d_unreachable(); }
const char *debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 75c0e421c..612c80282 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3680,9 +3680,12 @@ static unsigned int hlsl_offset_dim_count(enum hlsl_sampler_dim dim) case HLSL_SAMPLER_DIM_CUBEARRAY: /* Offset parameters not supported for these types. */ return 0; - default: - vkd3d_unreachable(); + + case HLSL_SAMPLER_DIM_GENERIC: + break; } + + vkd3d_unreachable(); }
static bool add_load_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *object, diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index fcd7cf93a..b977330c2 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2468,10 +2468,9 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type) return D3D_SVC_STRUCT; case HLSL_CLASS_VECTOR: return D3D_SVC_VECTOR; - default: - ERR("Invalid class %#x.\n", type->class); - vkd3d_unreachable(); } + + vkd3d_unreachable(); }
static D3D_SHADER_VARIABLE_TYPE sm4_base_type(const struct hlsl_type *type) @@ -2654,9 +2653,10 @@ static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *typ return D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; case HLSL_SAMPLER_DIM_CUBEARRAY: return D3D_SRV_DIMENSION_TEXTURECUBEARRAY; - default: - vkd3d_unreachable(); + case HLSL_SAMPLER_DIM_GENERIC: + break; } + vkd3d_unreachable(); }
static int sm4_compare_extern_resources(const void *a, const void *b) @@ -2951,9 +2951,10 @@ static enum vkd3d_sm4_resource_type sm4_resource_dimension(const struct hlsl_typ return VKD3D_SM4_RESOURCE_TEXTURE_2DMSARRAY; case HLSL_SAMPLER_DIM_CUBEARRAY: return VKD3D_SM4_RESOURCE_TEXTURE_CUBEARRAY; - default: - vkd3d_unreachable(); + case HLSL_SAMPLER_DIM_GENERIC: + break; } + vkd3d_unreachable(); }
struct sm4_instruction_modifier @@ -4374,7 +4375,7 @@ static void write_sm4_jump(struct hlsl_ctx *ctx, case HLSL_IR_JUMP_RETURN: vkd3d_unreachable();
- default: + case HLSL_IR_JUMP_CONTINUE: hlsl_fixme(ctx, &jump->node.loc, "Jump type %s.\n", hlsl_jump_type_to_string(jump->type)); return; } @@ -4676,6 +4677,10 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer * write_sm4_if(ctx, buffer, hlsl_ir_if(instr)); break;
+ case HLSL_IR_INDEX: + /* These should have been lowered. */ + vkd3d_unreachable(); + case HLSL_IR_JUMP: write_sm4_jump(ctx, buffer, hlsl_ir_jump(instr)); break; @@ -4703,9 +4708,6 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer * case HLSL_IR_SWIZZLE: write_sm4_swizzle(ctx, buffer, hlsl_ir_swizzle(instr)); break; - - default: - hlsl_fixme(ctx, &instr->loc, "Instruction type %s.", hlsl_node_type_to_string(instr->type)); } } }