From b514f411837be99b22d4df3a9b8e881a2021d087 Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Sun, 28 Jul 2019 14:26:00 -0400 Subject: glcpp: use pre-expansion line number for __LINE__ Fixes the following deqp tests: dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_* It don't see the spec requiring this, but it seems to be better, as the clang preprocessor for example has this behavior. Signed-off-by: Jonathan Marek Reviewed-by: Kenneth Graunke --- src/compiler/glsl/glcpp/glcpp-parse.y | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y index 1c095cb66f9..51bc85dcee7 100644 --- a/src/compiler/glsl/glcpp/glcpp-parse.y +++ b/src/compiler/glsl/glcpp/glcpp-parse.y @@ -1838,7 +1838,8 @@ _glcpp_parser_expand_function(glcpp_parser_t *parser, token_node_t *node, */ static token_list_t * _glcpp_parser_expand_node(glcpp_parser_t *parser, token_node_t *node, - token_node_t **last, expansion_mode_t mode) + token_node_t **last, expansion_mode_t mode, + int line) { token_t *token = node->token; const char *identifier; @@ -1857,8 +1858,7 @@ _glcpp_parser_expand_node(glcpp_parser_t *parser, token_node_t *node, * the hash table). */ if (*identifier == '_') { if (strcmp(identifier, "__LINE__") == 0) - return _token_list_create_with_one_integer(parser, - node->token->location.first_line); + return _token_list_create_with_one_integer(parser, line); if (strcmp(identifier, "__FILE__") == 0) return _token_list_create_with_one_integer(parser, @@ -1983,12 +1983,15 @@ _glcpp_parser_expand_token_list(glcpp_parser_t *parser, token_list_t *list, token_node_t *node, *last = NULL; token_list_t *expansion; active_list_t *active_initial = parser->active; + int line; if (list == NULL) return; _token_list_trim_trailing_space (list); + line = list->tail->token->location.last_line; + node_prev = NULL; node = list->head; @@ -2000,7 +2003,7 @@ _glcpp_parser_expand_token_list(glcpp_parser_t *parser, token_list_t *list, while (parser->active && parser->active->marker == node) _parser_active_list_pop (parser); - expansion = _glcpp_parser_expand_node (parser, node, &last, mode); + expansion = _glcpp_parser_expand_node (parser, node, &last, mode, line); if (expansion) { token_node_t *n; -- cgit v1.2.3