From be0e2e9b2ada51be66afb6b44330acb44e0261f2 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 07:29:22 -0700 Subject: Fix bug (and add tests) for a function-like macro defined as itself. This case worked previously, but broke in the recent rewrite of function- like macro expansion. The recursion was still terminated correctly, but any parenthesized expression after the macro name was still being swallowed even though the identifier was not being expanded as a macro. The fix is to notice earlier that the identifier is an already-expanding macro. We let the lexer know this through the classify_token function so that an already-expanding macro is lexed as an identifier, not a FUNC_MACRO. --- tests/032-define-func-self-recurse.c | 2 ++ tests/033-define-func-self-compose.c | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 tests/032-define-func-self-recurse.c create mode 100644 tests/033-define-func-self-compose.c (limited to 'tests') diff --git a/tests/032-define-func-self-recurse.c b/tests/032-define-func-self-recurse.c new file mode 100644 index 0000000000..60d8526c0a --- /dev/null +++ b/tests/032-define-func-self-recurse.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2 * (a)) +foo(3) diff --git a/tests/033-define-func-self-compose.c b/tests/033-define-func-self-compose.c new file mode 100644 index 0000000000..8abaaf6be9 --- /dev/null +++ b/tests/033-define-func-self-compose.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2 * (a)) +foo(foo(3)) -- cgit v1.2.3