Skip to content

Commit

Permalink
Implement struct_ref for return value
Browse files Browse the repository at this point in the history
  • Loading branch information
shinh committed Dec 11, 2016
1 parent 3dd51a8 commit 1121cdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ static void emit_load_struct_ref(Node *struc, Type *field, int off) {
emit_expr(struc->operand);
emit_lload(field, "rax", field->offset + off);
break;
case AST_FUNCALL: {
emit_expr(struc);
emit_lload(field, "rax", field->offset + off);
break;
}
default:
error("internal error: %s", node2s(struc));
}
Expand Down
1 change: 1 addition & 0 deletions test/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ static void struct_return(void) {
expect(21, sum_struct(6, return_struct_func(1, 2, 3, 4, 5)));
expect(55, sum_struct(sum_struct(0, return_struct_func(1, 2, 3, 4, 5)),
return_struct_func(6, 7, 8, 9, 10)));
expect(99, return_struct_func(1, 2, 3, 99, 4).z.b);
}

static int struct_arg_func_small(int v, struct abi_check_small s) {
Expand Down

0 comments on commit 1121cdb

Please sign in to comment.