From: Zebediah Figura Subject: [PATCH 3/5] d3dcompiler: Check for missing return value semantics on the entry point. Message-Id: <20200605221933.1861389-3-zfigura@codeweavers.com> Date: Fri, 5 Jun 2020 17:19:31 -0500 In-Reply-To: <20200605221933.1861389-1-zfigura@codeweavers.com> References: <20200605221933.1861389-1-zfigura@codeweavers.com> Signed-off-by: Zebediah Figura --- dlls/d3dcompiler_43/hlsl.y | 42 +++++++++++++++------------ dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 6 ++++ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index d5247d69b5c..d3b50e3858d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -2952,24 +2952,6 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino hlsl_parse(); - TRACE("Compilation status = %d\n", hlsl_ctx.status); - if (messages) - { - if (hlsl_ctx.messages.size) - *messages = hlsl_ctx.messages.string; - else - *messages = NULL; - } - else - { - if (hlsl_ctx.messages.capacity) - d3dcompiler_free(hlsl_ctx.messages.string); - } - - for (i = 0; i < hlsl_ctx.source_files_count; ++i) - d3dcompiler_free((void *)hlsl_ctx.source_files[i]); - d3dcompiler_free(hlsl_ctx.source_files); - if (hlsl_ctx.status == PARSE_ERR) goto out; @@ -2979,6 +2961,13 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino goto out; } + if (!type_is_void(entry_func->return_type) + && entry_func->return_type->type != HLSL_CLASS_STRUCT && !entry_func->semantic) + { + hlsl_report_message(entry_func->loc, HLSL_LEVEL_ERROR, + "entry point \"%s\" is missing a return value semantic", entry_func->func->name); + } + /* Index 0 means unused; index 1 means function entry, so start at 2. */ index_instructions(entry_func->body, 2); @@ -2991,6 +2980,23 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino compute_liveness(entry_func); out: + if (messages) + { + if (hlsl_ctx.messages.size) + *messages = hlsl_ctx.messages.string; + else + *messages = NULL; + } + else + { + if (hlsl_ctx.messages.capacity) + d3dcompiler_free(hlsl_ctx.messages.string); + } + + for (i = 0; i < hlsl_ctx.source_files_count; ++i) + d3dcompiler_free((void *)hlsl_ctx.source_files[i]); + d3dcompiler_free(hlsl_ctx.source_files); + TRACE("Freeing functions IR.\n"); wine_rb_destroy(&hlsl_ctx.functions, free_function_rb, NULL); diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 059f39e4c3e..16d1e6dda05 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1092,6 +1092,12 @@ static void test_fail(void) "{\n" " return float4(0, 0, 0, 0);\n" "}", + + /* 15 */ + "float4 test()\n" + "{\n" + " return float4(0, 0, 0, 0);\n" + "}", }; static const char *targets[] = {"ps_2_0", "ps_3_0", "ps_4_0"}; -- 2.26.2