History

Fix parsing function macro invocations

If a function macro name is separated from the parentheses in an macro invocation the substitution doesn't take place. Fix this by handling comments.

Michael Matz committed 14 years ago

Commit 4c0d70a1 parent 15f4ac22 files · +22 −3Browse files

Unified · Split

2 files
  1. tccpp.c +18 −3
  2. tests/tcctest.c +4 −0
tccpp.c+18−3
@@ -2697,10 +2697,25 @@ static int macro_subst_tok(TokenString *tok_str, · 2696 unmodified lines
26972697 goto redo;
26982698 }
26992699 } else {
2700− /* XXX: incorrect with comments */
27012700 ch = file->buf_ptr[0];
2702− while (is_space(ch) || ch == '\n')
2703− cinp();
2701+ while (is_space(ch) || ch == '\n' || ch == '/')
2702+ {
2703+ if (ch == '/')
2704+ {
2705+ int c;
2706+ uint8_t *p = file->buf_ptr;
2707+ PEEKC(c, p);
2708+ if (c == '*') {
2709+ p = parse_comment(p);
2710+ file->buf_ptr = p - 1;
2711+ } else if (c == '/') {
2712+ p = parse_line_comment(p);
2713+ file->buf_ptr = p - 1;
2714+ } else
2715+ break;
2716+ }
2717+ cinp();
2718+ }
27042719 t = ch;
27052720 }
27062721 if (t != '(') /* no macro subst */
tests/tcctest.c+4−0
@@ -288,6 +288,10 @@ comment · 287 unmodified lines
288288 /* test function macro substitution when the function name is
289289 substituted */
290290 TEST2();
291+
292+ /* And again when the name and parenthes are separated by a
293+ comment. */
294+ TEST2 /* the comment */ ();
291295 }
292296
293297

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