diff --git a/tccgen.c b/tccgen.c index e0b5fd6..562ab09 100644 --- a/tccgen.c +++ b/tccgen.c @@ -4589,7 +4589,7 @@ static void struct_layout(CType *type, AttributeDef *ad) /* pragma pack overrides align if lesser and packs bitfields always */ if (pragma_pack) { - packed = 1; + packed = pragma_pack; if (pragma_pack < align) align = pragma_pack; /* in pcc mode pragma pack also overrides individual align */ diff --git a/tccpp.c b/tccpp.c index 897ef15..3b343a6 100644 --- a/tccpp.c +++ b/tccpp.c @@ -1744,7 +1744,13 @@ static void pragma_parse(TCCState *s1) if (s1->pack_stack_ptr >= s1->pack_stack + PACK_STACK_SIZE - 1) goto stk_error; s1->pack_stack_ptr++; - skip(','); + if (tok == ')') { + *s1->pack_stack_ptr = *(s1->pack_stack_ptr - 1); + return; + } + if (tok !=',') + goto pragma_err; + next(); } if (tok != TOK_CINT) goto pragma_err; diff --git a/tests/tests2/60_errors_and_warnings.c b/tests/tests2/60_errors_and_warnings.c index 8a91512..b86f8c7 100644 --- a/tests/tests2/60_errors_and_warnings.c +++ b/tests/tests2/60_errors_and_warnings.c @@ -416,4 +416,6 @@ void func() fink(); } __attribute__((stuff)) int fink() {return 0;} +#elif defined test_pragma_pack_with_wrong_format +#pragma pack(push+1) #endif diff --git a/tests/tests2/60_errors_and_warnings.expect b/tests/tests2/60_errors_and_warnings.expect index a9dfa2d..6e5053b 100644 --- a/tests/tests2/60_errors_and_warnings.expect +++ b/tests/tests2/60_errors_and_warnings.expect @@ -203,3 +203,6 @@ bar : 3 ; 3 [test_switch_W4] 60_errors_and_warnings.c:416: warning: implicit declaration of function 'fink' 60_errors_and_warnings.c:418: error: 'stuff' attribute ignored + +[test_pragma_pack_with_wrong_format] +60_errors_and_warnings.c:420: error: malformed #pragma directive