Fix unicode compiler warning

The compiler warned about the unicode_to_utf8 code.
I fixed it by giving an error. This is the same as gcc does.
This commit is contained in:
herman ten brugge 2022-05-12 11:18:37 +02:00
parent e7396c99b0
commit 19cc80788d
3 changed files with 10 additions and 0 deletions

View File

@ -352,6 +352,7 @@ ST_INLN char *unicode_to_utf8 (char *b, uint32_t Uc)
else if (Uc-0xd800u<0x800) return b;
else if (Uc<0x10000) *b++=224+Uc/4096, *b++=128+Uc/64%64, *b++=128+Uc%64;
else if (Uc<0x110000) *b++=240+Uc/262144, *b++=128+Uc/4096%64, *b++=128+Uc/64%64, *b++=128+Uc%64;
else tcc_error("0x%x is not a valid universal character", Uc);
return b;
}

View File

@ -442,4 +442,10 @@ int f() { ({ return 78; }); }
int main() { return f(); }
/******************************************************************/
#elif defined test_illegal_unicode
int main() {
char *str = "\Uffffffff";
}
#endif

View File

@ -216,3 +216,6 @@ arg[1] = "Y"
[test_return_from_statement_expr]
[returns 78]
[test_illegal_unicode]
60_errors_and_warnings.c:448: error: 0xffffffff is not a valid universal character