Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 153 +++++++++++++++---------------------- 1 file changed, 63 insertions(+), 90 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 3d04677f2ec..e40494ddff8 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -32,7 +32,7 @@ int hlsl_lex(void); struct hlsl_parse_ctx hlsl_ctx;
struct YYLTYPE; -static void set_location(struct source_location *loc, const struct YYLTYPE *l); +static struct source_location get_location(const struct YYLTYPE *l);
void WINAPIV hlsl_message(const char *fmt, ...) { @@ -1214,7 +1214,7 @@ struct_declaration: struct_spec variables_def_optional ';' { struct source_location loc;
- set_location(&loc, &@3); + loc = get_location(&@3); if (!$2) { if (!$1->name) @@ -1236,7 +1236,7 @@ named_struct_spec: var_modifiers KW_STRUCT any_identifier '{' fields_list struct source_location loc;
TRACE("Structure %s declaration.\n", debugstr_a($3)); - set_location(&loc, &@1); + loc = get_location(&@1); check_invalid_matrix_modifiers($1, &loc); $$ = new_struct_type($3, $1, $5);
@@ -1261,7 +1261,7 @@ unnamed_struct_spec: var_modifiers KW_STRUCT '{' fields_list '}' struct source_location loc;
TRACE("Anonymous structure declaration.\n"); - set_location(&loc, &@1); + loc = get_location(&@1); check_invalid_matrix_modifiers($1, &loc); $$ = new_struct_type(NULL, $1, $4); } @@ -1344,7 +1344,7 @@ func_prototype: var_modifiers type var_identifier '(' parameters ')' c } $$.name = $3; $$.decl->semantic = $7.semantic; - set_location(&$$.decl->loc, &@3); + $$.decl->loc = get_location(&@3); hlsl_ctx.cur_function = $$.decl; }
@@ -1419,7 +1419,7 @@ param_list: parameter
$$ = d3dcompiler_alloc(sizeof(*$$)); list_init($$); - set_location(&loc, &@1); + loc = get_location(&@1); if (!add_func_parameter($$, &$1, &loc)) { ERR("Error adding function parameter %s.\n", $1.name); @@ -1432,7 +1432,7 @@ param_list: parameter struct source_location loc;
$$ = $1; - set_location(&loc, &@3); + loc = get_location(&@3); if (!add_func_parameter($$, &$3, &loc)) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -1594,7 +1594,7 @@ typedef: KW_TYPEDEF var_modifiers type type_specs ';' { struct source_location loc;
- set_location(&loc, &@1); + loc = get_location(&@1); if (!add_typedef($2, $3, $4, &loc)) YYABORT; } @@ -1602,7 +1602,7 @@ typedef: KW_TYPEDEF var_modifiers type type_specs ';' { struct source_location loc;
- set_location(&loc, &@1); + loc = get_location(&@1); if (!add_typedef(0, $2, $3, &loc)) YYABORT; } @@ -1622,7 +1622,7 @@ type_specs: type_spec type_spec: any_identifier array { $$ = d3dcompiler_alloc(sizeof(*$$)); - set_location(&$$->loc, &@1); + $$->loc = get_location(&@1); $$->name = $1; $$->array_size = $2; } @@ -1656,7 +1656,7 @@ variables_def: variable_def variable_def: any_identifier array colon_attribute { $$ = d3dcompiler_alloc(sizeof(*$$)); - set_location(&$$->loc, &@1); + $$->loc = get_location(&@1); $$->name = $1; $$->array_size = $2; $$->semantic = $3.semantic; @@ -1666,7 +1666,7 @@ variable_def: any_identifier array colon_attribute { TRACE("Declaration with initializer.\n"); $$ = d3dcompiler_alloc(sizeof(*$$)); - set_location(&$$->loc, &@1); + $$->loc = get_location(&@1); $$->name = $1; $$->array_size = $2; $$->semantic = $3.semantic; @@ -1803,11 +1803,8 @@ statement: declaration_statement
jump_statement: KW_RETURN expr ';' { - struct source_location loc; struct hlsl_ir_jump *jump; - - set_location(&loc, &@1); - if (!(jump = new_return(node_from_list($2), loc))) + if (!(jump = new_return(node_from_list($2), get_location(&@1)))) YYABORT;
$$ = $2; @@ -1815,13 +1812,9 @@ jump_statement: KW_RETURN expr ';' } | KW_RETURN ';' { - struct source_location loc; struct hlsl_ir_jump *jump; - - set_location(&loc, &@1); - if (!(jump = new_return(NULL, loc))) + if (!(jump = new_return(NULL, get_location(&@1)))) YYABORT; - $$ = d3dcompiler_alloc(sizeof(*$$)); list_init($$); list_add_tail($$, &jump->node.entry); @@ -1836,7 +1829,7 @@ selection_statement: KW_IF '(' expr ')' if_body YYABORT; } instr->node.type = HLSL_IR_IF; - set_location(&instr->node.loc, &@1); + instr->node.loc = get_location(&@1); instr->condition = node_from_list($3); instr->then_instrs = $5.then_instrs; instr->else_instrs = $5.else_instrs; @@ -1864,20 +1857,20 @@ if_body: statement loop_statement: KW_WHILE '(' expr ')' statement { struct source_location loc; - set_location(&loc, &@1); + loc = get_location(&@1); $$ = create_loop(LOOP_WHILE, NULL, $3, NULL, $5, &loc); } | KW_DO statement KW_WHILE '(' expr ')' ';' { struct source_location loc; - set_location(&loc, &@1); + loc = get_location(&@1); $$ = create_loop(LOOP_DO_WHILE, NULL, $5, NULL, $2, &loc); } | KW_FOR '(' scope_start expr_statement expr_statement expr ')' statement { struct source_location loc;
- set_location(&loc, &@1); + loc = get_location(&@1); $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, &loc); pop_scope(&hlsl_ctx); } @@ -1885,7 +1878,7 @@ loop_statement: KW_WHILE '(' expr ')' statement { struct source_location loc;
- set_location(&loc, &@1); + loc = get_location(&@1); if (!$4) hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_WARNING, "no expressions in for loop initializer"); @@ -1912,7 +1905,7 @@ primary_expr: C_FLOAT YYABORT; } c->node.type = HLSL_IR_CONSTANT; - set_location(&c->node.loc, &yylloc); + c->node.loc = get_location(&yylloc); c->node.data_type = new_hlsl_type(d3dcompiler_strdup("float"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1); c->v.value.f[0] = $1; if (!($$ = make_list(&c->node))) @@ -1927,7 +1920,7 @@ primary_expr: C_FLOAT YYABORT; } c->node.type = HLSL_IR_CONSTANT; - set_location(&c->node.loc, &yylloc); + c->node.loc = get_location(&yylloc); c->node.data_type = new_hlsl_type(d3dcompiler_strdup("int"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1); c->v.value.i[0] = $1; if (!($$ = make_list(&c->node))) @@ -1942,7 +1935,7 @@ primary_expr: C_FLOAT YYABORT; } c->node.type = HLSL_IR_CONSTANT; - set_location(&c->node.loc, &yylloc); + c->node.loc = get_location(&yylloc); c->node.data_type = new_hlsl_type(d3dcompiler_strdup("bool"), HLSL_CLASS_SCALAR, HLSL_TYPE_BOOL, 1, 1); c->v.value.b[0] = $1; if (!($$ = make_list(&c->node))) @@ -1962,7 +1955,7 @@ primary_expr: C_FLOAT } if ((deref = new_var_deref(var))) { - set_location(&deref->node.loc, &@1); + deref->node.loc = get_location(&@1); if (!($$ = make_list(&deref->node))) YYABORT; } @@ -1983,7 +1976,7 @@ postfix_expr: primary_expr struct source_location loc; struct hlsl_ir_node *inc;
- set_location(&loc, &@2); + loc = get_location(&@2); if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -2001,7 +1994,7 @@ postfix_expr: primary_expr struct source_location loc; struct hlsl_ir_node *inc;
- set_location(&loc, &@2); + loc = get_location(&@2); if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -2019,7 +2012,7 @@ postfix_expr: primary_expr struct hlsl_ir_node *node = node_from_list($1); struct source_location loc;
- set_location(&loc, &@2); + loc = get_location(&@2); if (node->data_type->type == HLSL_CLASS_STRUCT) { struct hlsl_type *type = node->data_type; @@ -2085,7 +2078,7 @@ postfix_expr: primary_expr YYABORT; } deref->node.type = HLSL_IR_DEREF; - set_location(&loc, &@2); + loc = get_location(&@2); deref->node.loc = loc; if (expr_type->type == HLSL_CLASS_ARRAY) { @@ -2159,7 +2152,7 @@ postfix_expr: primary_expr
constructor = d3dcompiler_alloc(sizeof(*constructor)); constructor->node.type = HLSL_IR_CONSTRUCTOR; - set_location(&constructor->node.loc, &@3); + constructor->node.loc = get_location(&@3); constructor->node.data_type = $2; constructor->args_count = $4.args_count; memcpy(constructor->args, $4.args, $4.args_count * sizeof(*$4.args)); @@ -2175,7 +2168,7 @@ unary_expr: postfix_expr { struct source_location loc;
- set_location(&loc, &@1); + loc = get_location(&@1); if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -2188,7 +2181,7 @@ unary_expr: postfix_expr { struct source_location loc;
- set_location(&loc, &@1); + loc = get_location(&@1); if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -2201,7 +2194,6 @@ unary_expr: postfix_expr { enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG, HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_BIT_NOT}; - struct source_location loc;
if ($1 == UNARY_OP_PLUS) { @@ -2209,8 +2201,7 @@ unary_expr: postfix_expr } else { - set_location(&loc, &@1); - $$ = append_unop($2, new_unary_expr(ops[$1], node_from_list($2), loc)); + $$ = append_unop($2, new_unary_expr(ops[$1], node_from_list($2), get_location(&@1))); } } /* var_modifiers just to avoid shift/reduce conflicts */ @@ -2220,7 +2211,7 @@ unary_expr: postfix_expr struct hlsl_type *dst_type; struct source_location loc;
- set_location(&loc, &@3); + loc = get_location(&@3); if ($2) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -2267,24 +2258,18 @@ mul_expr: unary_expr } | mul_expr '*' unary_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MUL, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MUL, + node_from_list($1), node_from_list($3), get_location(&@2))); } | mul_expr '/' unary_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_DIV, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_DIV, + node_from_list($1), node_from_list($3), get_location(&@2))); } | mul_expr '%' unary_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MOD, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MOD, + node_from_list($1), node_from_list($3), get_location(&@2))); }
add_expr: mul_expr @@ -2293,17 +2278,13 @@ add_expr: mul_expr } | add_expr '+' mul_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_ADD, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_ADD, + node_from_list($1), node_from_list($3), get_location(&@2))); } | add_expr '-' mul_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_SUB, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_SUB, + node_from_list($1), node_from_list($3), get_location(&@2))); }
shift_expr: add_expr @@ -2325,31 +2306,23 @@ relational_expr: shift_expr } | relational_expr '<' shift_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LESS, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LESS, + node_from_list($1), node_from_list($3), get_location(&@2))); } | relational_expr '>' shift_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GREATER, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GREATER, + node_from_list($1), node_from_list($3), get_location(&@2))); } | relational_expr OP_LE shift_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LEQUAL, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LEQUAL, + node_from_list($1), node_from_list($3), get_location(&@2))); } | relational_expr OP_GE shift_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GEQUAL, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GEQUAL, + node_from_list($1), node_from_list($3), get_location(&@2))); }
equality_expr: relational_expr @@ -2358,17 +2331,13 @@ equality_expr: relational_expr } | equality_expr OP_EQ relational_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_EQUAL, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_EQUAL, + node_from_list($1), node_from_list($3), get_location(&@2))); } | equality_expr OP_NE relational_expr { - struct source_location loc; - - set_location(&loc, &@2); - $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_NEQUAL, node_from_list($1), node_from_list($3), loc)); + $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_NEQUAL, + node_from_list($1), node_from_list($3), get_location(&@2))); }
bitand_expr: equality_expr @@ -2434,7 +2403,7 @@ assignment_expr: conditional_expr struct source_location loc; struct hlsl_ir_node *instr;
- set_location(&loc, &@2); + loc = get_location(&@2); if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) { hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, @@ -2506,11 +2475,15 @@ expr: assignment_expr
%%
-static void set_location(struct source_location *loc, const struct YYLTYPE *l) +static struct source_location get_location(const struct YYLTYPE *l) { - loc->file = hlsl_ctx.source_file; - loc->line = l->first_line; - loc->col = l->first_column; + const struct source_location loc = + { + .file = hlsl_ctx.source_file, + .line = l->first_line, + .col = l->first_column, + }; + return loc; }
static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 4 +- dlls/d3dcompiler_43/hlsl.y | 136 +++++++++------------- dlls/d3dcompiler_43/utils.c | 19 ++- 3 files changed, 67 insertions(+), 92 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index ab712c8d963..2d8eba0b554 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1061,8 +1061,8 @@ enum hlsl_error_level };
void WINAPIV hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN; -void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column, - enum hlsl_error_level level, const char *fmt, ...) PRINTF_ATTR(5,6) DECLSPEC_HIDDEN; +void WINAPIV hlsl_report_message(const struct source_location loc, + enum hlsl_error_level level, const char *fmt, ...) PRINTF_ATTR(3,4) DECLSPEC_HIDDEN;
static inline struct hlsl_ir_expr *expr_from_node(const struct hlsl_ir_node *node) { diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index e40494ddff8..593090ed357 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -54,7 +54,7 @@ static const char *hlsl_get_error_level_name(enum hlsl_error_level level) return names[level]; }
-void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column, +void WINAPIV hlsl_report_message(const struct source_location loc, enum hlsl_error_level level, const char *fmt, ...) { __ms_va_list args; @@ -86,7 +86,8 @@ void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column, } }
- hlsl_message("%s:%u:%u: %s: %s\n", filename, line, column, hlsl_get_error_level_name(level), string); + hlsl_message("%s:%u:%u: %s: %s\n", loc.file, loc.line, loc.col, + hlsl_get_error_level_name(level), string); d3dcompiler_free(string);
if (level == HLSL_LEVEL_ERROR) @@ -97,7 +98,13 @@ void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column,
static void hlsl_error(const char *s) { - hlsl_report_message(hlsl_ctx.source_file, hlsl_ctx.line_no, hlsl_ctx.column, HLSL_LEVEL_ERROR, "%s", s); + const struct source_location loc = + { + .file = hlsl_ctx.source_file, + .line = hlsl_ctx.line_no, + .col = hlsl_ctx.column, + }; + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "%s", s); }
static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char *declname, unsigned int line_no) @@ -112,7 +119,7 @@ static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_locati { if (modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) { - hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR, + hlsl_report_message(*loc, HLSL_LEVEL_ERROR, "'row_major' or 'column_major' modifiers are only allowed for matrices"); } } @@ -139,12 +146,12 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) | HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM); if (invalid) { - hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(decl->loc, HLSL_LEVEL_ERROR, "modifier '%s' invalid for local variables", debug_modifiers(invalid)); } if (decl->semantic) { - hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(decl->loc, HLSL_LEVEL_ERROR, "semantics are not allowed on local variables"); return FALSE; } @@ -153,8 +160,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) { if (find_function(decl->name)) { - hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR, - "redefinition of '%s'", decl->name); + hlsl_report_message(decl->loc, HLSL_LEVEL_ERROR, "redefinition of '%s'", decl->name); return FALSE; } } @@ -163,10 +169,8 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) { struct hlsl_ir_var *old = get_variable(hlsl_ctx.cur_scope, decl->name);
- hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR, - ""%s" already declared", decl->name); - hlsl_report_message(old->loc.file, old->loc.line, old->loc.col, HLSL_LEVEL_NOTE, - ""%s" was previously declared here", old->name); + hlsl_report_message(decl->loc, HLSL_LEVEL_ERROR, ""%s" already declared", decl->name); + hlsl_report_message(old->loc, HLSL_LEVEL_NOTE, ""%s" was previously declared here", old->name); return FALSE; } return TRUE; @@ -178,8 +182,7 @@ static BOOL check_type_modifiers(DWORD modifiers, struct source_location *loc) { if (modifiers & ~HLSL_TYPE_MODIFIERS_MASK) { - hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR, - "modifier not allowed on typedefs"); + hlsl_report_message(*loc, HLSL_LEVEL_ERROR, "modifier not allowed on typedefs"); return FALSE; } return TRUE; @@ -503,8 +506,7 @@ static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *value, struct source } else if (return_type->base_type != HLSL_TYPE_VOID) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "non-void function must return a value"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "non-void function must return a value"); d3dcompiler_free(jump); return NULL; } @@ -523,8 +525,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
if (initializer_size(initializer) != components_count_type(type)) { - hlsl_report_message(var->loc.file, var->loc.line, var->loc.col, HLSL_LEVEL_ERROR, - "structure initializer mismatch"); + hlsl_report_message(var->loc, HLSL_LEVEL_ERROR, "structure initializer mismatch"); free_parse_initializer(initializer); return; } @@ -621,8 +622,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
if (var->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count) { - hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, - HLSL_LEVEL_ERROR, "const variable without initializer"); + hlsl_report_message(v->loc, HLSL_LEVEL_ERROR, "const variable without initializer"); free_declaration(var); d3dcompiler_free(v); continue; @@ -648,7 +648,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, { if (size < type->dimx * type->dimy) { - hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(v->loc, HLSL_LEVEL_ERROR, "'%s' initializer does not match", v->name); free_parse_initializer(&v->initializer); d3dcompiler_free(v); @@ -658,7 +658,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY) && components_count_type(type) != size) { - hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(v->loc, HLSL_LEVEL_ERROR, "'%s' initializer does not match", v->name); free_parse_initializer(&v->initializer); d3dcompiler_free(v); @@ -751,8 +751,7 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s field->semantic = v->semantic; if (v->initializer.args_count) { - hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR, - "struct field with an initializer.\n"); + hlsl_report_message(v->loc, HLSL_LEVEL_ERROR, "struct field with an initializer.\n"); free_parse_initializer(&v->initializer); } list_add_tail(list, &field->entry); @@ -818,7 +817,7 @@ static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct lis ret = add_type_to_scope(hlsl_ctx.cur_scope, type); if (!ret) { - hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(v->loc, HLSL_LEVEL_ERROR, "redefinition of custom type '%s'", v->name); } d3dcompiler_free(v); @@ -1148,18 +1147,16 @@ hlsl_prog: /* empty */ { if (decl->body && $2.decl->body) { - hlsl_report_message($2.decl->loc.file, $2.decl->loc.line, - $2.decl->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message($2.decl->loc, HLSL_LEVEL_ERROR, "redefinition of function %s", debugstr_a($2.name)); YYABORT; } else if (!compare_hlsl_types(decl->return_type, $2.decl->return_type)) { - hlsl_report_message($2.decl->loc.file, $2.decl->loc.line, - $2.decl->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message($2.decl->loc, HLSL_LEVEL_ERROR, "redefining function %s with a different return type", debugstr_a($2.name)); - hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_NOTE, + hlsl_report_message(decl->loc, HLSL_LEVEL_NOTE, "%s previously declared here", debugstr_a($2.name)); YYABORT; @@ -1168,8 +1165,7 @@ hlsl_prog: /* empty */
if ($2.decl->return_type->base_type == HLSL_TYPE_VOID && $2.decl->semantic) { - hlsl_report_message($2.decl->loc.file, $2.decl->loc.line, - $2.decl->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message($2.decl->loc, HLSL_LEVEL_ERROR, "void function with a semantic"); }
@@ -1219,8 +1215,8 @@ struct_declaration: struct_spec variables_def_optional ';' { if (!$1->name) { - hlsl_report_message(loc.file, loc.line, loc.col, - HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, + "anonymous struct declaration with no variables"); } check_type_modifiers($1->modifiers, &loc); } @@ -1242,7 +1238,7 @@ named_struct_spec: var_modifiers KW_STRUCT any_identifier '{' fields_list
if (get_variable(hlsl_ctx.cur_scope, $3)) { - hlsl_report_message(hlsl_ctx.source_file, @3.first_line, @3.first_column, + hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "redefinition of '%s'", $3); YYABORT; } @@ -1250,7 +1246,7 @@ named_struct_spec: var_modifiers KW_STRUCT any_identifier '{' fields_list ret = add_type_to_scope(hlsl_ctx.cur_scope, $$); if (!ret) { - hlsl_report_message(hlsl_ctx.source_file, @3.first_line, @3.first_column, + hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "redefinition of struct '%s'", $3); YYABORT; } @@ -1286,7 +1282,7 @@ fields_list: /* Empty */ ret = add_struct_field($$, field); if (ret == FALSE) { - hlsl_report_message(hlsl_ctx.source_file, @2.first_line, @2.first_column, + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "redefinition of '%s'", field->name); d3dcompiler_free(field); } @@ -1321,13 +1317,13 @@ func_prototype: var_modifiers type var_identifier '(' parameters ')' c { if (get_variable(hlsl_ctx.globals, $3)) { - hlsl_report_message(hlsl_ctx.source_file, @3.first_line, @3.first_column, + hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "redefinition of '%s'\n", $3); YYABORT; } if ($2->base_type == HLSL_TYPE_VOID && $7.semantic) { - hlsl_report_message(hlsl_ctx.source_file, @7.first_line, @7.first_column, + hlsl_report_message(get_location(&@7), HLSL_LEVEL_ERROR, "void function with a semantic"); }
@@ -1435,7 +1431,7 @@ param_list: parameter loc = get_location(&@3); if (!add_func_parameter($$, &$3, &loc)) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "duplicate parameter %s", $3.name); YYABORT; } @@ -1459,8 +1455,8 @@ input_mods: /* Empty */ { if ($1 & $2) { - hlsl_report_message(hlsl_ctx.source_file, @2.first_line, @2.first_column, - HLSL_LEVEL_ERROR, "duplicate input-output modifiers"); + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, + "duplicate input-output modifiers"); YYABORT; } $$ = $1 | $2; @@ -1835,8 +1831,7 @@ selection_statement: KW_IF '(' expr ')' if_body instr->else_instrs = $5.else_instrs; if (instr->condition->data_type->dimx > 1 || instr->condition->data_type->dimy > 1) { - hlsl_report_message(instr->node.loc.file, instr->node.loc.line, - instr->node.loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(instr->node.loc, HLSL_LEVEL_ERROR, "if condition requires a scalar"); } $$ = $3; @@ -1880,7 +1875,7 @@ loop_statement: KW_WHILE '(' expr ')' statement
loc = get_location(&@1); if (!$4) - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_WARNING, + hlsl_report_message(loc, HLSL_LEVEL_WARNING, "no expressions in for loop initializer"); $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, &loc); pop_scope(&hlsl_ctx); @@ -1979,8 +1974,7 @@ postfix_expr: primary_expr loc = get_location(&@2); if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "modifying a const expression"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "modifying a const expression"); YYABORT; } inc = new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), loc); @@ -1997,8 +1991,7 @@ postfix_expr: primary_expr loc = get_location(&@2); if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "modifying a const expression"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "modifying a const expression"); YYABORT; } inc = new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), loc); @@ -2037,7 +2030,7 @@ postfix_expr: primary_expr } if (!$$) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "invalid subscript %s", debugstr_a($3)); YYABORT; } @@ -2049,7 +2042,7 @@ postfix_expr: primary_expr swizzle = get_swizzle(node, $3, &loc); if (!swizzle) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "invalid swizzle %s", debugstr_a($3)); YYABORT; } @@ -2057,7 +2050,7 @@ postfix_expr: primary_expr } else { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "invalid subscript %s", debugstr_a($3)); YYABORT; } @@ -2069,7 +2062,6 @@ postfix_expr: primary_expr * We store it as an array dereference in any case. */ struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref)); struct hlsl_type *expr_type = node_from_list($1)->data_type; - struct source_location loc;
TRACE("Array dereference from type %s\n", debug_hlsl_type(expr_type)); if (!deref) @@ -2078,8 +2070,7 @@ postfix_expr: primary_expr YYABORT; } deref->node.type = HLSL_IR_DEREF; - loc = get_location(&@2); - deref->node.loc = loc; + deref->node.loc = get_location(&@2); if (expr_type->type == HLSL_CLASS_ARRAY) { deref->node.data_type = expr_type->e.array.type; @@ -2095,11 +2086,9 @@ postfix_expr: primary_expr else { if (expr_type->type == HLSL_CLASS_SCALAR) - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "array-indexed expression is scalar"); + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "array-indexed expression is scalar"); else - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "expression is not array-indexable"); + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "expression is not array-indexable"); d3dcompiler_free(deref); free_instr_list($1); free_instr_list($3); @@ -2107,8 +2096,7 @@ postfix_expr: primary_expr } if (node_from_list($3)->data_type->type != HLSL_CLASS_SCALAR) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "array index is not scalar"); + hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "array index is not scalar"); d3dcompiler_free(deref); free_instr_list($1); free_instr_list($3); @@ -2171,8 +2159,7 @@ unary_expr: postfix_expr loc = get_location(&@1); if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "modifying a const expression"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "modifying a const expression"); YYABORT; } $$ = append_unop($2, new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), loc)); @@ -2184,8 +2171,7 @@ unary_expr: postfix_expr loc = get_location(&@1); if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "modifying a const expression"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "modifying a const expression"); YYABORT; } $$ = append_unop($2, new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), loc)); @@ -2214,8 +2200,7 @@ unary_expr: postfix_expr loc = get_location(&@3); if ($2) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "unexpected modifier in a cast"); + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "unexpected modifier in a cast"); YYABORT; }
@@ -2226,8 +2211,7 @@ unary_expr: postfix_expr
if (!compatible_data_types(src_type, dst_type)) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "can't cast from %s to %s", + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "can't cast from %s to %s", debug_hlsl_type(src_type), debug_hlsl_type(dst_type)); YYABORT; } @@ -2400,20 +2384,17 @@ assignment_expr: conditional_expr } | unary_expr assign_op assignment_expr { - struct source_location loc; struct hlsl_ir_node *instr;
- loc = get_location(&@2); if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) { - hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR, - "l-value is const"); + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); YYABORT; } if (!(instr = make_assignment(node_from_list($1), $2, BWRITERSP_WRITEMASK_ALL, node_from_list($3)))) YYABORT; - instr->loc = loc; + instr->loc = get_location(&@2); $$ = append_binop($3, $1, instr); }
@@ -2486,19 +2467,18 @@ static struct source_location get_location(const struct YYLTYPE *l) return loc; }
-static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc) +static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *l) { if (modifiers & mod) { - hlsl_report_message(hlsl_ctx.source_file, loc->first_line, loc->first_column, HLSL_LEVEL_ERROR, + hlsl_report_message(get_location(l), HLSL_LEVEL_ERROR, "modifier '%s' already specified", debug_modifiers(mod)); return modifiers; } if (mod & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR) && modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) { - hlsl_report_message(hlsl_ctx.source_file, loc->first_line, loc->first_column, HLSL_LEVEL_ERROR, - "more than one matrix majority keyword"); + hlsl_report_message(get_location(l), HLSL_LEVEL_ERROR, "more than one matrix majority keyword"); return modifiers; } return modifiers | mod; diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 28ec47423ab..5eaff1730b3 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1191,8 +1191,7 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type
if (t1->type > HLSL_CLASS_LAST_NUMERIC || t2->type > HLSL_CLASS_LAST_NUMERIC) { - hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR, - "non scalar/vector/matrix data type in expression"); + hlsl_report_message(*loc, HLSL_LEVEL_ERROR, "non scalar/vector/matrix data type in expression"); return NULL; }
@@ -1201,8 +1200,7 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type
if (!expr_compatible_data_types(t1, t2)) { - hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR, - "expression data types are incompatible"); + hlsl_report_message(*loc, HLSL_LEVEL_ERROR, "expression data types are incompatible"); return NULL; }
@@ -1286,14 +1284,13 @@ struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_
if (!implicit_compatible_data_types(src_type, dst_type)) { - hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR, - "can't implicitly convert %s to %s", debug_hlsl_type(src_type), debug_hlsl_type(dst_type)); + hlsl_report_message(*loc, HLSL_LEVEL_ERROR, "can't implicitly convert %s to %s", + debug_hlsl_type(src_type), debug_hlsl_type(dst_type)); return NULL; }
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy) - hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_WARNING, - "implicit truncation of vector type"); + hlsl_report_message(*loc, HLSL_LEVEL_WARNING, "implicit truncation of vector type");
TRACE("Implicit conversion from %s to %s.\n", debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
@@ -1341,9 +1338,7 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope if (operands[i]->data_type->dimx * operands[i]->data_type->dimy != 1 && operands[i]->data_type->dimx * operands[i]->data_type->dimy != type->dimx * type->dimy) { - hlsl_report_message(operands[i]->loc.file, - operands[i]->loc.line, operands[i]->loc.col, HLSL_LEVEL_WARNING, - "implicit truncation of vector/matrix type"); + hlsl_report_message(operands[i]->loc, HLSL_LEVEL_WARNING, "implicit truncation of vector/matrix type"); }
if (!(cast = new_cast(operands[i], type, &operands[i]->loc))) @@ -1452,7 +1447,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
if (left->data_type->type > HLSL_CLASS_LAST_NUMERIC) { - hlsl_report_message(left->loc.file, left->loc.line, left->loc.col, HLSL_LEVEL_ERROR, + hlsl_report_message(left->loc, HLSL_LEVEL_ERROR, "writemask on a non scalar/vector/matrix type"); d3dcompiler_free(assign); return NULL;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 593090ed357..e91c2a08eb3 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -826,7 +826,7 @@ static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct lis return TRUE; }
-static BOOL add_func_parameter(struct list *list, struct parse_parameter *param, const struct source_location *loc) +static BOOL add_func_parameter(struct list *list, struct parse_parameter *param, const struct source_location loc) { struct hlsl_ir_var *decl = d3dcompiler_alloc(sizeof(*decl));
@@ -836,7 +836,7 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param, return FALSE; } decl->data_type = param->type; - decl->loc = *loc; + decl->loc = loc; decl->name = param->name; decl->semantic = param->semantic; decl->reg_reservation = param->reg_reservation; @@ -1411,12 +1411,9 @@ parameters: scope_start
param_list: parameter { - struct source_location loc; - $$ = d3dcompiler_alloc(sizeof(*$$)); list_init($$); - loc = get_location(&@1); - if (!add_func_parameter($$, &$1, &loc)) + if (!add_func_parameter($$, &$1, get_location(&@1))) { ERR("Error adding function parameter %s.\n", $1.name); set_parse_status(&hlsl_ctx.status, PARSE_ERR); @@ -1425,13 +1422,10 @@ param_list: parameter } | param_list ',' parameter { - struct source_location loc; - $$ = $1; - loc = get_location(&@3); - if (!add_func_parameter($$, &$3, &loc)) + if (!add_func_parameter($$, &$3, get_location(&@3))) { - hlsl_report_message(loc, HLSL_LEVEL_ERROR, + hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "duplicate parameter %s", $3.name); YYABORT; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 52 ++++++++++++++------------------------ 1 file changed, 19 insertions(+), 33 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index e91c2a08eb3..4bf5599e52e 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -178,16 +178,6 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc);
-static BOOL check_type_modifiers(DWORD modifiers, struct source_location *loc) -{ - if (modifiers & ~HLSL_TYPE_MODIFIERS_MASK) - { - hlsl_report_message(*loc, HLSL_LEVEL_ERROR, "modifier not allowed on typedefs"); - return FALSE; - } - return TRUE; -} - static BOOL add_type_to_scope(struct hlsl_scope *scope, struct hlsl_type *def) { if (get_type(scope, def->name, FALSE)) @@ -781,21 +771,12 @@ static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, stru return type; }
-static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct list *list, - struct source_location *loc) +static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct list *list) { BOOL ret; struct hlsl_type *type; struct parse_variable_def *v, *v_next;
- if (!check_type_modifiers(modifiers, loc)) - { - LIST_FOR_EACH_ENTRY_SAFE(v, v_next, list, struct parse_variable_def, entry) - d3dcompiler_free(v); - d3dcompiler_free(list); - return FALSE; - } - LIST_FOR_EACH_ENTRY_SAFE(v, v_next, list, struct parse_variable_def, entry) { if (v->array_size) @@ -1208,17 +1189,18 @@ preproc_directive: PRE_LINE STRING
struct_declaration: struct_spec variables_def_optional ';' { - struct source_location loc; - - loc = get_location(&@3); if (!$2) { if (!$1->name) { - hlsl_report_message(loc, HLSL_LEVEL_ERROR, + hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); } - check_type_modifiers($1->modifiers, &loc); + if ($1->modifiers) + { + hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, + "modifier not allowed on struct type declaration"); + } } $$ = declare_vars($1, 0, $2); } @@ -1582,18 +1564,22 @@ declaration_statement: declaration
typedef: KW_TYPEDEF var_modifiers type type_specs ';' { - struct source_location loc; - - loc = get_location(&@1); - if (!add_typedef($2, $3, $4, &loc)) + if ($2 & ~HLSL_TYPE_MODIFIERS_MASK) + { + struct parse_variable_def *v, *v_next; + hlsl_report_message(get_location(&@1), + HLSL_LEVEL_ERROR, "modifier not allowed on typedefs"); + LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry) + d3dcompiler_free(v); + d3dcompiler_free($4); + YYABORT; + } + if (!add_typedef($2, $3, $4)) YYABORT; } | KW_TYPEDEF struct_spec type_specs ';' { - struct source_location loc; - - loc = get_location(&@1); - if (!add_typedef(0, $2, $3, &loc)) + if (!add_typedef(0, $2, $3)) YYABORT; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 4bf5599e52e..8f66deb90df 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -115,11 +115,11 @@ static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char TRACE("%s %s;\n", debug_hlsl_type(type), declname); }
-static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_location *loc) +static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_location loc) { if (modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) { - hlsl_report_message(*loc, HLSL_LEVEL_ERROR, + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "'row_major' or 'column_major' modifiers are only allowed for matrices"); } } @@ -138,7 +138,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) } } else - check_invalid_matrix_modifiers(decl->modifiers, &decl->loc); + check_invalid_matrix_modifiers(decl->modifiers, decl->loc);
if (local) { @@ -793,7 +793,7 @@ static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct lis type->modifiers |= modifiers;
if (type->type != HLSL_CLASS_MATRIX) - check_invalid_matrix_modifiers(type->modifiers, &v->loc); + check_invalid_matrix_modifiers(type->modifiers, v->loc);
ret = add_type_to_scope(hlsl_ctx.cur_scope, type); if (!ret) @@ -1211,11 +1211,9 @@ struct_spec: named_struct_spec named_struct_spec: var_modifiers KW_STRUCT any_identifier '{' fields_list '}' { BOOL ret; - struct source_location loc;
TRACE("Structure %s declaration.\n", debugstr_a($3)); - loc = get_location(&@1); - check_invalid_matrix_modifiers($1, &loc); + check_invalid_matrix_modifiers($1, get_location(&@1)); $$ = new_struct_type($3, $1, $5);
if (get_variable(hlsl_ctx.cur_scope, $3)) @@ -1236,11 +1234,8 @@ named_struct_spec: var_modifiers KW_STRUCT any_identifier '{' fields_list
unnamed_struct_spec: var_modifiers KW_STRUCT '{' fields_list '}' { - struct source_location loc; - TRACE("Anonymous structure declaration.\n"); - loc = get_location(&@1); - check_invalid_matrix_modifiers($1, &loc); + check_invalid_matrix_modifiers($1, get_location(&@1)); $$ = new_struct_type(NULL, $1, $4); }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 8f66deb90df..e46bdbade3f 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -301,7 +301,7 @@ enum loop_type };
static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond, - struct list *iter, struct list *body, struct source_location *loc) + struct list *iter, struct list *body, struct source_location loc) { struct list *list = NULL; struct hlsl_ir_loop *loop = NULL; @@ -319,7 +319,7 @@ static struct list *create_loop(enum loop_type type, struct list *init, struct l if (!loop) goto oom; loop->node.type = HLSL_IR_LOOP; - loop->node.loc = *loc; + loop->node.loc = loc; list_add_tail(list, &loop->node.entry); loop->body = d3dcompiler_alloc(sizeof(*loop->body)); if (!loop->body) @@ -1826,33 +1826,23 @@ if_body: statement
loop_statement: KW_WHILE '(' expr ')' statement { - struct source_location loc; - loc = get_location(&@1); - $$ = create_loop(LOOP_WHILE, NULL, $3, NULL, $5, &loc); + $$ = create_loop(LOOP_WHILE, NULL, $3, NULL, $5, get_location(&@1)); } | KW_DO statement KW_WHILE '(' expr ')' ';' { - struct source_location loc; - loc = get_location(&@1); - $$ = create_loop(LOOP_DO_WHILE, NULL, $5, NULL, $2, &loc); + $$ = create_loop(LOOP_DO_WHILE, NULL, $5, NULL, $2, get_location(&@1)); } | KW_FOR '(' scope_start expr_statement expr_statement expr ')' statement { - struct source_location loc; - - loc = get_location(&@1); - $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, &loc); + $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, get_location(&@1)); pop_scope(&hlsl_ctx); } | KW_FOR '(' scope_start declaration expr_statement expr ')' statement { - struct source_location loc; - - loc = get_location(&@1); if (!$4) - hlsl_report_message(loc, HLSL_LEVEL_WARNING, + hlsl_report_message(get_location(&@4), HLSL_LEVEL_WARNING, "no expressions in for loop initializer"); - $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, &loc); + $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, get_location(&@1)); pop_scope(&hlsl_ctx); }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com