| @@ -4176,20 +4176,25 @@ static int parse_btype(CType *type, AttributeDef *ad) · 4175 unmodified lines |
| 4176 | goto basic_type; | 4176 | goto basic_type; |
| 4177 | case TOK_ALIGNAS: | 4177 | case TOK_ALIGNAS: |
| 4178 | { int n; | 4178 | { int n; |
| 4179 | next(); | 4179 | AttributeDef ad1; |
| 4180 | /* TODO: _Alignas(type) -> _Alignas(_Alignof(type)) */ | 4180 | next(); |
| 4181 | if (tok == '(') { | 4181 | skip('('); |
| 4182 | next(); | 4182 | memset(&ad1, 0, sizeof(AttributeDef)); |
| 4183 | n = expr_const(); | 4183 | if (parse_btype(&type1, &ad1)) { |
| 4184 | if (n <= 0 || (n & (n - 1)) != 0) | 4184 | type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); |
| | 4185 | if (ad1.a.aligned) |
| | 4186 | n = 1 << (ad1.a.aligned - 1); |
| | 4187 | else |
| | 4188 | type_size(&type1, &n); |
| | 4189 | } else { |
| | 4190 | n = expr_const(); |
| | 4191 | if (n <= 0 || (n & (n - 1)) != 0) |
| 4185 | tcc_error("alignment must be a positive power of two"); | 4192 | tcc_error("alignment must be a positive power of two"); |
| 4186 | skip(')'); | 4193 | } |
| 4187 | } else { | 4194 | skip(')'); |
| 4188 | expect("("); | 4195 | ad->a.aligned = exact_log2p1(n); |
| 4189 | } | 4196 | } |
| 4190 | ad->a.aligned = exact_log2p1(n); | 4197 | continue; |
| 4191 | } | | |
| 4192 | continue; | | |
| 4193 | case TOK_LONG: | 4198 | case TOK_LONG: |
| 4194 | if ((t & VT_BTYPE) == VT_DOUBLE) { | 4199 | if ((t & VT_BTYPE) == VT_DOUBLE) { |
| 4195 | t = (t & ~(VT_BTYPE|VT_LONG)) | VT_LDOUBLE; | 4200 | t = (t & ~(VT_BTYPE|VT_LONG)) | VT_LDOUBLE; |
| @@ -4594,22 +4599,6 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td) · 398 unmodified lines |
| 4594 | case TOK_RESTRICT2: | 4599 | case TOK_RESTRICT2: |
| 4595 | case TOK_RESTRICT3: | 4600 | case TOK_RESTRICT3: |
| 4596 | goto redo; | 4601 | goto redo; |
| 4597 | case TOK_ALIGNAS: | | |
| 4598 | { int n; | | |
| 4599 | next(); | | |
| 4600 | /* TODO: _Alignas(type) -> _Alignas(_Alignof(type)) */ | | |
| 4601 | if (tok == '(') { | | |
| 4602 | next(); | | |
| 4603 | n = expr_const(); | | |
| 4604 | if (n <= 0 || (n & (n - 1)) != 0) | | |
| 4605 | tcc_error("alignment must be a positive power of two"); | | |
| 4606 | skip(')'); | | |
| 4607 | } else { | | |
| 4608 | expect("("); | | |
| 4609 | } | | |
| 4610 | ad->a.aligned = exact_log2p1(n); | | |
| 4611 | } | | |
| 4612 | break; | | |
| 4613 | /* XXX: clarify attribute handling */ | 4602 | /* XXX: clarify attribute handling */ |
| 4614 | case TOK_ATTRIBUTE1: | 4603 | case TOK_ATTRIBUTE1: |
| 4615 | case TOK_ATTRIBUTE2: | 4604 | case TOK_ATTRIBUTE2: |