History

Produce better error message on malformed while loop

echo "void bugged() { do {} }" | tcc -run - now produces the sensible: -:1: error: 'while' expected (got "}") I believe (but am far from sure) that the additional use of &tokc is ok.

Eric Raible committed 3 years ago

Commit b214fb61 parent 3d128041 file · +5 −2Browse files

Unified · Split

tccpp.c+5−2
@@ -98,8 +98,11 @@ static void next_nomacro(void); · 97 unmodified lines
9898
9999 ST_FUNC void skip(int c)
100100 {
101− if (tok != c)
102− tcc_error("'%c' expected (got \"%s\")", c, get_tok_str(tok, &tokc));
101+ if (tok != c) {
102+ char tmp[40];
103+ pstrcpy(tmp, sizeof tmp, get_tok_str(c, &tokc));
104+ tcc_error("'%s' expected (got \"%s\")", tmp, get_tok_str(tok, &tokc));
105+ }
103106 next();
104107 }
105108

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