diff options
author | Carl Worth <cworth@cworth.org> | 2010-05-19 07:49:47 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-05-19 07:49:47 -0700 |
commit | 59ca98990f814926d716a13b0201c94945133824 (patch) | |
tree | 74406859f754d1ad185b3e6dbbd52a047c41b1d7 | |
parent | 69f390d6096c597dbe63f20fd02b2312da211de8 (diff) |
Fix bug as in previous fix, but with multi-token argument.
The previous fix added FUNC_MACRO to a production one higher in teh
grammar than it should have. So it prevented a FUNC_MACRO from
appearing as part of a mutli-token argument rather than just alone as
an argument. Fix this (and add a test).
-rw-r--r-- | glcpp-parse.y | 22 | ||||
-rw-r--r-- | tests/035-define-func-self-compose-non-func-multi-token-argument.c | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y index ea27184c47..400f138d17 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -94,7 +94,7 @@ _argument_list_member_at (argument_list_t *list, int index); %lex-param {void *scanner} %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO REPLACEMENT TOKEN UNDEF -%type <str> FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN word +%type <str> argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN %type <string_list> argument macro parameter_list %type <argument_list> argument_list @@ -165,18 +165,14 @@ argument_list: ; argument: - word { + argument_word { $$ = _string_list_create (parser); _string_list_append_item ($$, $1); } | macro { $$ = _string_list_create (parser); } -| FUNC_MACRO { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); - } -| argument word { +| argument argument_word { _string_list_append_item ($1, $2); talloc_free ($2); $$ = $1; @@ -189,6 +185,13 @@ argument: } ; +argument_word: + IDENTIFIER { $$ = $1; } +| TOKEN { $$ = $1; } +| FUNC_MACRO { $$ = $1; } +; + + directive: DEFINE IDENTIFIER REPLACEMENT { _define_object_macro (parser, $2, $3); @@ -225,11 +228,6 @@ parameter_list: } ; -word: - IDENTIFIER { $$ = $1; } -| TOKEN { $$ = $1; } -; - %% string_list_t * diff --git a/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/tests/035-define-func-self-compose-non-func-multi-token-argument.c new file mode 100644 index 0000000000..9955219470 --- /dev/null +++ b/tests/035-define-func-self-compose-non-func-multi-token-argument.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(1 + foo) |