diff options
author | Carl Worth <cworth@cworth.org> | 2010-05-19 07:42:42 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-05-19 07:42:42 -0700 |
commit | 69f390d6096c597dbe63f20fd02b2312da211de8 (patch) | |
tree | 33638607813a1efa040b74009a6861c390ff6d6c | |
parent | be0e2e9b2ada51be66afb6b44330acb44e0261f2 (diff) |
Fix bug (and test) for an invocation using macro name as a non-macro argument
This adds a second shift/reduce conflict to our grammar. It's basically the
same conflict we had previously, (deciding to shift a '(' after a FUNC_MACRO)
but this time in the "argument" context rather than the "content" context.
It would be nice to not have these, but I think they are unavoidable
(withotu a lot of pain at least) given the preprocessor specification.
-rw-r--r-- | glcpp-parse.y | 10 | ||||
-rw-r--r-- | tests/034-define-func-self-compose-non-func.c | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y index 8dc07483c1..ea27184c47 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -103,8 +103,12 @@ _argument_list_member_at (argument_list_t *list, int index); * 1. '(' after FUNC_MACRO name which is correctly resolved to shift * to form macro invocation rather than reducing directly to * content. + * + * 2. Similarly, '(' after FUNC_MACRO which is correctly resolved to + * shift to form macro invocation rather than reducing directly to + * argument. */ -%expect 1 +%expect 2 %% @@ -168,6 +172,10 @@ argument: | macro { $$ = _string_list_create (parser); } +| FUNC_MACRO { + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); + } | argument word { _string_list_append_item ($1, $2); talloc_free ($2); diff --git a/tests/034-define-func-self-compose-non-func.c b/tests/034-define-func-self-compose-non-func.c new file mode 100644 index 0000000000..209a5f7e07 --- /dev/null +++ b/tests/034-define-func-self-compose-non-func.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(foo) |