From b214fb6ed3897bf364d512b59f7f43fce6540de9 Mon Sep 17 00:00:00 2001 From: Eric Raible Date: Tue, 3 Oct 2023 22:11:59 -0700 Subject: [PATCH] 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. --- tccpp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tccpp.c b/tccpp.c index 43a616c0..ae9ae003 100644 --- a/tccpp.c +++ b/tccpp.c @@ -98,8 +98,11 @@ static void next_nomacro(void); ST_FUNC void skip(int c) { - if (tok != c) - tcc_error("'%c' expected (got \"%s\")", c, get_tok_str(tok, &tokc)); + if (tok != c) { + char tmp[40]; + pstrcpy(tmp, sizeof tmp, get_tok_str(c, &tokc)); + tcc_error("'%s' expected (got \"%s\")", tmp, get_tok_str(tok, &tokc)); + } next(); }