Integrate upstream chibicc changes
This commit is contained in:
8
third_party/chibicc/codegen.c
vendored
8
third_party/chibicc/codegen.c
vendored
@ -342,6 +342,13 @@ void gen_addr(Node *node) {
|
||||
gen_expr(node->lhs);
|
||||
gen_addr(node->rhs);
|
||||
return;
|
||||
case ND_ASSIGN:
|
||||
case ND_COND:
|
||||
if (node->ty->kind == TY_STRUCT || node->ty->kind == TY_UNION) {
|
||||
gen_expr(node);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case ND_MEMBER:
|
||||
gen_addr(node->lhs);
|
||||
if (node->member->offset) {
|
||||
@ -358,7 +365,6 @@ void gen_addr(Node *node) {
|
||||
println("\tlea\t%d(%%rbp),%%rax", node->var->offset);
|
||||
return;
|
||||
default:
|
||||
DCHECK(0);
|
||||
error_tok(node->tok, "not an lvalue %d", node->kind);
|
||||
}
|
||||
}
|
||||
|
||||
18
third_party/chibicc/test/struct_test.c
vendored
18
third_party/chibicc/test/struct_test.c
vendored
@ -374,6 +374,24 @@ int main() {
|
||||
};
|
||||
sizeof(T);
|
||||
}));
|
||||
ASSERT(2, ({
|
||||
struct {
|
||||
int a;
|
||||
} x = {1}, y = {2};
|
||||
(x = y).a;
|
||||
}));
|
||||
ASSERT(1, ({
|
||||
struct {
|
||||
int a;
|
||||
} x = {1}, y = {2};
|
||||
(1 ? x : y).a;
|
||||
}));
|
||||
ASSERT(2, ({
|
||||
struct {
|
||||
int a;
|
||||
} x = {1}, y = {2};
|
||||
(0 ? x : y).a;
|
||||
}));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user