From 1252930bc0a2b12604bc8e5ae350e985b36e6514 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Mon, 16 Jul 2012 20:39:21 +0200 Subject: [PATCH] d3dcompiler: Variables and functions can't have the same name. --- dlls/d3dcompiler_43/hlsl.y | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index b4214025a40..eedf357b3d9 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -132,8 +132,17 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) "modifier '%s' invalid for local variables", debug_modifiers(invalid)); } } + else + { + if (find_function(decl->name)) + { + hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR, + "redefinition of '%s'", decl->name); + return FALSE; + } + } ret = add_declaration(hlsl_ctx.cur_scope, decl, local); - if (ret == FALSE) + if (!ret) { struct hlsl_ir_var *old = get_variable(hlsl_ctx.cur_scope, decl->name); @@ -381,6 +390,13 @@ func_declaration: func_prototype compound_statement func_prototype: var_modifiers type var_identifier '(' parameters ')' semantic { + if (get_variable(hlsl_ctx.globals, $3)) + { + hlsl_report_message(hlsl_ctx.source_file, @3.first_line, @3.first_column, + HLSL_LEVEL_ERROR, "redefinition of '%s'\n", $3); + return 1; + } + $$ = new_func_decl($3, $2, $5); if (!$$) { -- 2.11.4.GIT