History

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.

herman ten brugge committed 4 years ago

Commit 19cc8071 parent e7396c93 files · +10 −0Browse files

Unified · Split

3 files
  1. tccpp.c +1 −0
  2. tests/tests2/60_errors_and_warnings.c +6 −0
  3. tests/tests2/60_errors_and_warnings.expect +3 −0
tccpp.c+1−0
@@ -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
tests/tests2/60_errors_and_warnings.c+6−0
@@ -442,4 +442,10 @@ int f() { ({ return 78; }); } · 441 unmodified lines
442int main() { return f(); }442int main() { return f(); }
443 443
444/******************************************************************/444/******************************************************************/
445
446#elif defined test_illegal_unicode
447int main() {
448 char *str = "\Uffffffff";
449}
450
445#endif451#endif
tests/tests2/60_errors_and_warnings.expect+3−0
@@ -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]
22160_errors_and_warnings.c:448: error: 0xffffffff is not a valid universal character

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t