Do not allow to obtain an address of a bitfield

This commit is contained in:
Rui Ueyama 2020-08-23 12:38:17 +09:00
parent 17ea802cea
commit c302a969d8
1 changed files with 7 additions and 2 deletions

View File

@ -2003,8 +2003,13 @@ static Node *unary(Token **rest, Token *tok) {
if (equal(tok, "-"))
return new_unary(ND_NEG, cast(rest, tok->next), tok);
if (equal(tok, "&"))
return new_unary(ND_ADDR, cast(rest, tok->next), tok);
if (equal(tok, "&")) {
Node *lhs = cast(rest, tok->next);
add_type(lhs);
if (lhs->kind == ND_MEMBER && lhs->member->is_bitfield)
error_tok(tok, "cannot take address of bitfield");
return new_unary(ND_ADDR, lhs, tok);
}
if (equal(tok, "*")) {
// [https://www.sigbus.info/n1570#6.5.3.2p4] This is an oddity