Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/facebook/luaffifb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames R. McKaskill <james@foobar.co.nz>2012-04-22 08:14:16 +0400
committerJames R. McKaskill <james@foobar.co.nz>2012-04-22 08:14:46 +0400
commitceffc3b13f3cadafc499bca18c61ea35ab337dba (patch)
treee02e0a1a3e5dd008b6d924d287f15a1b020230d4 /parser.c
parent10b007fcd5a71e867e8fa9cbe80afac106bcd060 (diff)
Fix aligned attribute on GCC
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/parser.c b/parser.c
index 2c3f04a..1ed2fee 100644
--- a/parser.c
+++ b/parser.c
@@ -310,6 +310,7 @@ static void calculate_member_position(lua_State* L, struct parser* P, struct cty
if (mt->is_variable_struct || mt->is_variable_array) {
luaL_error(L, "NYI: variable sized members in unions");
+ return;
} else if (mt->is_bitfield) {
msize = (mt->align_mask + 1);
@@ -1007,25 +1008,26 @@ static int parse_attribute(lua_State* L, struct parser* P, struct token* tok, st
return luaL_error(L, "unexpected token in align on line %d", P->line);
}
- /* TODO: strictly speaking __attribute__(aligned(#)) is only
- * supposed to increase alignment
+ /* __attribute__(aligned(#)) is only supposed to increase alignment
*/
- switch (tok->integer) {
- /* TODO: atm we just leave this as it was, but is there a
- * better way of handling this
- */
- case 0: break;
- case 1: ct->align_mask = 0; break;
- case 2: ct->align_mask = 1; break;
- case 4: ct->align_mask = 3; break;
- case 8: ct->align_mask = 7; break;
- case 16: ct->align_mask = 15; break;
- default:
- return luaL_error(L, "unsupported align size on line %d", P->line);
+ if (IS_LITERAL(*tok, "align") || tok->integer > ct->align_mask) {
+ switch (tok->integer) {
+ /* TODO: atm we just leave this as it was, but is there a
+ * better way of handling this
+ */
+ case 0: break;
+ case 1: ct->align_mask = 0; break;
+ case 2: ct->align_mask = 1; break;
+ case 4: ct->align_mask = 3; break;
+ case 8: ct->align_mask = 7; break;
+ case 16: ct->align_mask = 15; break;
+ default:
+ return luaL_error(L, "unsupported align size on line %d", P->line);
+ }
+ ct->align_is_forced = 1;
}
- ct->align_is_forced = 1;
check_token(L, P, TOK_CLOSE_PAREN, NULL, "expected align(#) on line %d", P->line);
} else if (IS_LITERAL(*tok, "packed")) {