diff options
| author | Michael Matz <matz@suse.de> | 2016-07-11 18:38:00 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-12-15 17:47:08 +0100 |
| commit | 2b618c1ab4b9a4b8bd9c362cff070fa40cd03353 (patch) | |
| tree | 44e92b1b1b45f937656278baf2f3cb726ff147a1 /tccgen.c | |
| parent | 7e515466246b30f02867fc1f1902dea706ff31af (diff) | |
| download | tinycc-2b618c1ab4b9a4b8bd9c362cff070fa40cd03353.tar.gz tinycc-2b618c1ab4b9a4b8bd9c362cff070fa40cd03353.tar.bz2 | |
Fix parsing attributes for struct decls
Given this code:
struct __attribute__((...)) Name {...};
TCC was eating "Name", hence generating an anonymous struct.
It also didn't apply any packed attributes to the parsed
members. Both fixed. The testcase also contains a case
that isn't yet handled by TCC (under a BROKEN #define).
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -3179,10 +3179,8 @@ static void struct_decl(CType *type, AttributeDef *ad, int u) a = tok; /* save decl type */ next(); - if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2) { + if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2) parse_attribute(ad); - next(); - } if (tok != '{') { v = tok; next(); @@ -3302,7 +3300,7 @@ static void struct_decl(CType *type, AttributeDef *ad, int u) if (ad1.a.aligned) { if (align < ad1.a.aligned) align = ad1.a.aligned; - } else if (ad1.a.packed) { + } else if (ad1.a.packed || ad->a.packed) { align = 1; } else if (*tcc_state->pack_stack_ptr) { if (align > *tcc_state->pack_stack_ptr) |
