d3dcompiler: Clarify error messages related to misplaced type modifiers.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-03-03 20:29:49 -06:00 committed by Alexandre Julliard
parent 3048fb9064
commit 0d47e9bde4
1 changed files with 19 additions and 33 deletions

View File

@ -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 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) static BOOL add_type_to_scope(struct hlsl_scope *scope, struct hlsl_type *def)
{ {
if (get_type(scope, def->name, FALSE)) 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; return type;
} }
static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct list *list, static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct list *list)
struct source_location *loc)
{ {
BOOL ret; BOOL ret;
struct hlsl_type *type; struct hlsl_type *type;
struct parse_variable_def *v, *v_next; 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) LIST_FOR_EACH_ENTRY_SAFE(v, v_next, list, struct parse_variable_def, entry)
{ {
if (v->array_size) if (v->array_size)
@ -1208,17 +1189,18 @@ preproc_directive: PRE_LINE STRING
struct_declaration: struct_spec variables_def_optional ';' struct_declaration: struct_spec variables_def_optional ';'
{ {
struct source_location loc;
loc = get_location(&@3);
if (!$2) if (!$2)
{ {
if (!$1->name) 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"); "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); $$ = declare_vars($1, 0, $2);
} }
@ -1582,18 +1564,22 @@ declaration_statement: declaration
typedef: KW_TYPEDEF var_modifiers type type_specs ';' typedef: KW_TYPEDEF var_modifiers type type_specs ';'
{ {
struct source_location loc; if ($2 & ~HLSL_TYPE_MODIFIERS_MASK)
{
loc = get_location(&@1); struct parse_variable_def *v, *v_next;
if (!add_typedef($2, $3, $4, &loc)) 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; YYABORT;
} }
| KW_TYPEDEF struct_spec type_specs ';' | KW_TYPEDEF struct_spec type_specs ';'
{ {
struct source_location loc; if (!add_typedef(0, $2, $3))
loc = get_location(&@1);
if (!add_typedef(0, $2, $3, &loc))
YYABORT; YYABORT;
} }