d3dcompiler: Parse return statements without a value.
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:
parent
8b08fec5e3
commit
e597b9e555
|
@ -481,6 +481,28 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const cha
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *value, struct source_location loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_jump *jump = d3dcompiler_alloc(sizeof(*jump));
|
||||||
|
if (!jump)
|
||||||
|
{
|
||||||
|
ERR("Out of memory\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
jump->node.type = HLSL_IR_JUMP;
|
||||||
|
jump->node.loc = loc;
|
||||||
|
jump->type = HLSL_IR_JUMP_RETURN;
|
||||||
|
jump->node.data_type = value ? value->data_type
|
||||||
|
: new_hlsl_type(d3dcompiler_strdup("void"), HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
|
||||||
|
jump->return_value = value;
|
||||||
|
|
||||||
|
FIXME("Check for valued return on void function.\n");
|
||||||
|
FIXME("Implicit conversion to the return type if needed, "
|
||||||
|
"error out if conversion not possible.\n");
|
||||||
|
|
||||||
|
return jump;
|
||||||
|
}
|
||||||
|
|
||||||
static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
|
static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
|
||||||
struct parse_initializer *initializer)
|
struct parse_initializer *initializer)
|
||||||
{
|
{
|
||||||
|
@ -1769,28 +1791,31 @@ statement: declaration_statement
|
||||||
| selection_statement
|
| selection_statement
|
||||||
| loop_statement
|
| loop_statement
|
||||||
|
|
||||||
/* FIXME: add rule for return with no value */
|
|
||||||
jump_statement: KW_RETURN expr ';'
|
jump_statement: KW_RETURN expr ';'
|
||||||
{
|
{
|
||||||
struct hlsl_ir_jump *jump = d3dcompiler_alloc(sizeof(*jump));
|
struct source_location loc;
|
||||||
if (!jump)
|
struct hlsl_ir_jump *jump;
|
||||||
{
|
|
||||||
ERR("Out of memory\n");
|
|
||||||
YYABORT;
|
|
||||||
}
|
|
||||||
jump->node.type = HLSL_IR_JUMP;
|
|
||||||
set_location(&jump->node.loc, &@1);
|
|
||||||
jump->type = HLSL_IR_JUMP_RETURN;
|
|
||||||
jump->node.data_type = node_from_list($2)->data_type;
|
|
||||||
jump->return_value = node_from_list($2);
|
|
||||||
|
|
||||||
FIXME("Check for valued return on void function.\n");
|
set_location(&loc, &@1);
|
||||||
FIXME("Implicit conversion to the return type if needed, "
|
if (!(jump = new_return(node_from_list($2), loc)))
|
||||||
"error out if conversion not possible.\n");
|
YYABORT;
|
||||||
|
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
list_add_tail($$, &jump->node.entry);
|
list_add_tail($$, &jump->node.entry);
|
||||||
}
|
}
|
||||||
|
| KW_RETURN ';'
|
||||||
|
{
|
||||||
|
struct source_location loc;
|
||||||
|
struct hlsl_ir_jump *jump;
|
||||||
|
|
||||||
|
set_location(&loc, &@1);
|
||||||
|
if (!(jump = new_return(NULL, loc)))
|
||||||
|
YYABORT;
|
||||||
|
|
||||||
|
$$ = d3dcompiler_alloc(sizeof(*$$));
|
||||||
|
list_init($$);
|
||||||
|
list_add_tail($$, &jump->node.entry);
|
||||||
|
}
|
||||||
|
|
||||||
selection_statement: KW_IF '(' expr ')' if_body
|
selection_statement: KW_IF '(' expr ')' if_body
|
||||||
{
|
{
|
||||||
|
|
|
@ -730,7 +730,7 @@ static void test_fail(void)
|
||||||
compiled = errors = NULL;
|
compiled = errors = NULL;
|
||||||
hr = ppD3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", targets[j], 0, 0, &compiled, &errors);
|
hr = ppD3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", targets[j], 0, 0, &compiled, &errors);
|
||||||
todo_wine ok(hr == E_FAIL, "Test %u, target %s, got unexpected hr %#x.\n", i, targets[j], hr);
|
todo_wine ok(hr == E_FAIL, "Test %u, target %s, got unexpected hr %#x.\n", i, targets[j], hr);
|
||||||
todo_wine_if (i == 1 || i >= 8) ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
|
todo_wine_if (i == 1 || i >= 7) ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
|
||||||
ok(!compiled, "Test %u, target %s, expected no compiled shader blob.\n", i, targets[j]);
|
ok(!compiled, "Test %u, target %s, expected no compiled shader blob.\n", i, targets[j]);
|
||||||
if (errors)
|
if (errors)
|
||||||
ID3D10Blob_Release(errors);
|
ID3D10Blob_Release(errors);
|
||||||
|
|
Loading…
Reference in New Issue