Commit e597b9e5 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Parse return statements without a value.

parent 8b08fec5
......@@ -481,6 +481,28 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const cha
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,
struct parse_initializer *initializer)
{
......@@ -1769,28 +1791,31 @@ statement: declaration_statement
| selection_statement
| loop_statement
/* FIXME: add rule for return with no value */
jump_statement: KW_RETURN expr ';'
{
struct hlsl_ir_jump *jump = d3dcompiler_alloc(sizeof(*jump));
if (!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);
struct source_location loc;
struct hlsl_ir_jump *jump;
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");
set_location(&loc, &@1);
if (!(jump = new_return(node_from_list($2), loc)))
YYABORT;
$$ = $2;
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
{
......
......@@ -730,7 +730,7 @@ static void test_fail(void)
compiled = errors = NULL;
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_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]);
if (errors)
ID3D10Blob_Release(errors);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment