History

tccpp.c: fix ##-in-macros logic

The old code had an inverted condition, so #define a(b)## b would be accepted while #define a(b,c) b ## ## c would be rejected with the confusing error message "'##' invalid at start of macro".

Philip committed 11 years ago

Commit 3a922ad1 parent a6b94ef1 file · +2 −2Browse files

Unified · Split

tccpp.c+2−2
@@ -1296,7 +1296,7 @@ ST_FUNC void parse_define(void) · 1295 unmodified lines
1296 ptok = 0;1296 ptok = 0;
1297 macro_list_start = 1;1297 macro_list_start = 1;
1298 while (tok != TOK_LINEFEED && tok != TOK_EOF) {1298 while (tok != TOK_LINEFEED && tok != TOK_EOF) {
1299 if (!macro_list_start && spc == 2 && tok == TOK_TWOSHARPS)1299 if (macro_list_start && spc == 2 && tok == TOK_TWOSHARPS)
1300 tcc_error("'##' invalid at start of macro");1300 tcc_error("'##' invalid at start of macro");
1301 ptok = tok;1301 ptok = tok;
1302 /* remove spaces around ## and after '#' */1302 /* remove spaces around ## and after '#' */
@@ -1310,9 +1310,9 @@ ST_FUNC void parse_define(void) · 7 unmodified lines
1310 goto skip;1310 goto skip;
1311 }1311 }
1312 tok_str_add2(&str, tok, &tokc);1312 tok_str_add2(&str, tok, &tokc);
1313 macro_list_start = 0;
1313 skip:1314 skip:
1314 next_nomacro_spc();1315 next_nomacro_spc();
1315 macro_list_start = 0;
1316 }1316 }
1317 if (ptok == TOK_TWOSHARPS)1317 if (ptok == TOK_TWOSHARPS)
1318 tcc_error("'##' invalid at end of macro");1318 tcc_error("'##' invalid at end of macro");

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