From b569383bbdfa22ed591255f56fb93832633a95ae Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 08:01:44 -0700 Subject: Avoid re-expanding a macro name that has once been rejected from expansion. The specification of the preprocessor in C99 says that when we see a macro name that we are already expanding that we refuse to expand it now, (which we've done for a while), but also that we refuse to ever expand it later if seen in other contexts at which it would be legitimate to expand. We add a test case for that here, and fix it to work. The fix takes advantage of a new token_t value for tokens and argument words along with the recently added IDENTIFIER_FINALIZED token type which instructs the parser to not even look for another expansion. --- glcpp.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'glcpp.h') diff --git a/glcpp.h b/glcpp.h index c647e2a72e..5432a31817 100644 --- a/glcpp.h +++ b/glcpp.h @@ -42,6 +42,11 @@ typedef struct string_list { string_node_t *tail; } string_list_t; +typedef struct token { + int type; + char *value; +} token_t; + typedef struct token_node { int type; const char *value; @@ -68,6 +73,7 @@ typedef struct glcpp_parser glcpp_parser_t; typedef enum { TOKEN_CLASS_ARGUMENT, TOKEN_CLASS_IDENTIFIER, + TOKEN_CLASS_IDENTIFIER_FINALIZED, TOKEN_CLASS_FUNC_MACRO, TOKEN_CLASS_OBJ_MACRO } token_class_t; -- cgit v1.2.3