_Noreturn, just like __attribute__((noreturn)), is ignored. I also added stdnoreturn.h, in all its glorious uselessness. _Alignas only works for integer expressions right now. In order to comply, we need: - _Alignas(type) -> _Alignas(_Alignof(type)). - stdalign.h as soon as it is done. Note: DR 444 is supported; it works on struct members.
Unified · Split
| @@ -0,0 +1,7 @@ | |||
| 1 | #ifndef _STDNORETURN_H | ||
| 2 | #define _STDNORETURN_H | ||
| 3 | |||
| 4 | /* ISOC11 noreturn */ | ||
| 5 | #define noreturn _Noreturn | ||
| 6 | |||
| 7 | #endif /* _STDNORETURN_H */ | ||
| @@ -4172,6 +4172,22 @@ static int parse_btype(CType *type, AttributeDef *ad) · 4171 unmodified lines | |||
| 4172 | case TOK_INT: | 4172 | case TOK_INT: |
| 4173 | u = VT_INT; | 4173 | u = VT_INT; |
| 4174 | goto basic_type; | 4174 | goto basic_type; |
| 4175 | case TOK_ALIGNAS: | ||
| 4176 | { int n; | ||
| 4177 | next(); | ||
| 4178 | /* TODO: _Alignas(type) -> _Alignas(_Alignof(type)) */ | ||
| 4179 | if (tok == '(') { | ||
| 4180 | next(); | ||
| 4181 | n = expr_const(); | ||
| 4182 | if (n <= 0 || (n & (n - 1)) != 0) | ||
| 4183 | tcc_error("alignment must be a positive power of two"); | ||
| 4184 | skip(')'); | ||
| 4185 | } else { | ||
| 4186 | expect("("); | ||
| 4187 | } | ||
| 4188 | ad->a.aligned = exact_log2p1(n); | ||
| 4189 | } | ||
| 4190 | continue; | ||
| 4175 | case TOK_LONG: | 4191 | case TOK_LONG: |
| 4176 | if ((t & VT_BTYPE) == VT_DOUBLE) { | 4192 | if ((t & VT_BTYPE) == VT_DOUBLE) { |
| 4177 | t = (t & ~(VT_BTYPE|VT_LONG)) | VT_LDOUBLE; | 4193 | t = (t & ~(VT_BTYPE|VT_LONG)) | VT_LDOUBLE; |
| @@ -4281,7 +4297,11 @@ static int parse_btype(CType *type, AttributeDef *ad) · 103 unmodified lines | |||
| 4281 | t |= VT_INLINE; | 4297 | t |= VT_INLINE; |
| 4282 | next(); | 4298 | next(); |
| 4283 | break; | 4299 | break; |
| 4284 | 4300 | case TOK_NORETURN3: | |
| 4301 | /* currently, no need to handle it because tcc does not | ||
| 4302 | track unused objects */ | ||
| 4303 | next(); | ||
| 4304 | break; | ||
| 4285 | /* GNUC attribute */ | 4305 | /* GNUC attribute */ |
| 4286 | case TOK_ATTRIBUTE1: | 4306 | case TOK_ATTRIBUTE1: |
| 4287 | case TOK_ATTRIBUTE2: | 4307 | case TOK_ATTRIBUTE2: |
| @@ -4569,6 +4589,22 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td) · 281 unmodified lines | |||
| 4569 | case TOK_RESTRICT2: | 4589 | case TOK_RESTRICT2: |
| 4570 | case TOK_RESTRICT3: | 4590 | case TOK_RESTRICT3: |
| 4571 | goto redo; | 4591 | goto redo; |
| 4592 | case TOK_ALIGNAS: | ||
| 4593 | { int n; | ||
| 4594 | next(); | ||
| 4595 | /* TODO: _Alignas(type) -> _Alignas(_Alignof(type)) */ | ||
| 4596 | if (tok == '(') { | ||
| 4597 | next(); | ||
| 4598 | n = expr_const(); | ||
| 4599 | if (n <= 0 || (n & (n - 1)) != 0) | ||
| 4600 | tcc_error("alignment must be a positive power of two"); | ||
| 4601 | skip(')'); | ||
| 4602 | } else { | ||
| 4603 | expect("("); | ||
| 4604 | } | ||
| 4605 | ad->a.aligned = exact_log2p1(n); | ||
| 4606 | } | ||
| 4607 | break; | ||
| 4572 | /* XXX: clarify attribute handling */ | 4608 | /* XXX: clarify attribute handling */ |
| 4573 | case TOK_ATTRIBUTE1: | 4609 | case TOK_ATTRIBUTE1: |
| 4574 | case TOK_ATTRIBUTE2: | 4610 | case TOK_ATTRIBUTE2: |
| @@ -54,6 +54,7 @@ · 53 unmodified lines | |||
| 54 | DEF(TOK_ALIGNOF1, "__alignof") | 54 | DEF(TOK_ALIGNOF1, "__alignof") |
| 55 | DEF(TOK_ALIGNOF2, "__alignof__") | 55 | DEF(TOK_ALIGNOF2, "__alignof__") |
| 56 | DEF(TOK_ALIGNOF3, "_Alignof") | 56 | DEF(TOK_ALIGNOF3, "_Alignof") |
| 57 | DEF(TOK_ALIGNAS, "_Alignas") | ||
| 57 | DEF(TOK_TYPEOF1, "typeof") | 58 | DEF(TOK_TYPEOF1, "typeof") |
| 58 | DEF(TOK_TYPEOF2, "__typeof") | 59 | DEF(TOK_TYPEOF2, "__typeof") |
| 59 | DEF(TOK_TYPEOF3, "__typeof__") | 60 | DEF(TOK_TYPEOF3, "__typeof__") |
| @@ -138,6 +139,7 @@ · 78 unmodified lines | |||
| 138 | DEF(TOK_NODECORATE, "nodecorate") | 139 | DEF(TOK_NODECORATE, "nodecorate") |
| 139 | DEF(TOK_NORETURN1, "noreturn") | 140 | DEF(TOK_NORETURN1, "noreturn") |
| 140 | DEF(TOK_NORETURN2, "__noreturn__") | 141 | DEF(TOK_NORETURN2, "__noreturn__") |
| 142 | DEF(TOK_NORETURN3, "_Noreturn") | ||
| 141 | DEF(TOK_VISIBILITY1, "visibility") | 143 | DEF(TOK_VISIBILITY1, "visibility") |
| 142 | DEF(TOK_VISIBILITY2, "__visibility__") | 144 | DEF(TOK_VISIBILITY2, "__visibility__") |
| 143 | 145 | ||