The compiler warned about the unicode_to_utf8 code. I fixed it by giving an error. This is the same as gcc does.
Unified · Split
| @@ -352,6 +352,7 @@ ST_INLN char *unicode_to_utf8 (char *b, uint32_t Uc) · 351 unmodified lines | |||
| 352 | else if (Uc-0xd800u<0x800) return b; | 352 | else if (Uc-0xd800u<0x800) return b; |
| 353 | else if (Uc<0x10000) *b++=224+Uc/4096, *b++=128+Uc/64%64, *b++=128+Uc%64; | 353 | else if (Uc<0x10000) *b++=224+Uc/4096, *b++=128+Uc/64%64, *b++=128+Uc%64; |
| 354 | else if (Uc<0x110000) *b++=240+Uc/262144, *b++=128+Uc/4096%64, *b++=128+Uc/64%64, *b++=128+Uc%64; | 354 | else if (Uc<0x110000) *b++=240+Uc/262144, *b++=128+Uc/4096%64, *b++=128+Uc/64%64, *b++=128+Uc%64; |
| 355 | else tcc_error("0x%x is not a valid universal character", Uc); | ||
| 355 | return b; | 356 | return b; |
| 356 | } | 357 | } |
| 357 | 358 | ||
| @@ -442,4 +442,10 @@ int f() { ({ return 78; }); } · 441 unmodified lines | |||
| 442 | int main() { return f(); } | 442 | int main() { return f(); } |
| 443 | 443 | ||
| 444 | /******************************************************************/ | 444 | /******************************************************************/ |
| 445 | |||
| 446 | #elif defined test_illegal_unicode | ||
| 447 | int main() { | ||
| 448 | char *str = "\Uffffffff"; | ||
| 449 | } | ||
| 450 | |||
| 445 | #endif | 451 | #endif |
| @@ -216,3 +216,6 @@ arg[1] = "Y" · 215 unmodified lines | |||
| 216 | 216 | ||
| 217 | [test_return_from_statement_expr] | 217 | [test_return_from_statement_expr] |
| 218 | [returns 78] | 218 | [returns 78] |
| 219 | |||
| 220 | [test_illegal_unicode] | ||
| 221 | 60_errors_and_warnings.c:448: error: 0xffffffff is not a valid universal character | ||