diff options
| author | Michael Matz <matz@suse.de> | 2012-04-16 00:21:40 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2012-04-18 20:57:13 +0200 |
| commit | 4c0d70ab07b4a5a5040e53259f8e9cedd4ec89b2 (patch) | |
| tree | dd91e5de8da11315ca1d55db52c5ab427989a648 | |
| parent | 15f4ac2b1a4453b73904bb2ff4441498d5911a64 (diff) | |
| download | tinycc-4c0d70ab07b4a5a5040e53259f8e9cedd4ec89b2.tar.gz tinycc-4c0d70ab07b4a5a5040e53259f8e9cedd4ec89b2.tar.bz2 | |
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.
| -rw-r--r-- | tccpp.c | 21 | ||||
| -rw-r--r-- | tests/tcctest.c | 4 |
2 files changed, 22 insertions, 3 deletions
@@ -2697,10 +2697,25 @@ static int macro_subst_tok(TokenString *tok_str, goto redo; } } else { - /* XXX: incorrect with comments */ ch = file->buf_ptr[0]; - while (is_space(ch) || ch == '\n') - cinp(); + while (is_space(ch) || ch == '\n' || ch == '/') + { + if (ch == '/') + { + int c; + uint8_t *p = file->buf_ptr; + PEEKC(c, p); + if (c == '*') { + p = parse_comment(p); + file->buf_ptr = p - 1; + } else if (c == '/') { + p = parse_line_comment(p); + file->buf_ptr = p - 1; + } else + break; + } + cinp(); + } t = ch; } if (t != '(') /* no macro subst */ diff --git a/tests/tcctest.c b/tests/tcctest.c index eee7039..eeabb7c 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -288,6 +288,10 @@ comment /* test function macro substitution when the function name is substituted */ TEST2(); + + /* And again when the name and parenthes are separated by a + comment. */ + TEST2 /* the comment */ (); } |
