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
2697 goto redo;2697 goto redo;
2698 }2698 }
2699 } else {2699 } else {
2700 /* XXX: incorrect with comments */
2701 ch = file->buf_ptr[0];2700 ch = file->buf_ptr[0];
2702 while (is_space(ch) || ch == '\n')2701 while (is_space(ch) || ch == '\n' || ch == '/')
2703 cinp();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 }
2704 t = ch;2719 t = ch;
2705 }2720 }
2706 if (t != '(') /* no macro subst */2721 if (t != '(') /* no macro subst */
tests/tcctest.c+4−0
@@ -288,6 +288,10 @@ comment · 287 unmodified lines
288 /* test function macro substitution when the function name is288 /* test function macro substitution when the function name is
289 substituted */289 substituted */
290 TEST2();290 TEST2();
291
292 /* And again when the name and parenthes are separated by a
293 comment. */
294 TEST2 /* the comment */ ();
291}295}
292 296
293 297

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