diff options
author | Jonathan Marek <[email protected]> | 2019-07-28 14:26:00 -0400 |
---|---|---|
committer | Jonathan Marek <[email protected]> | 2019-08-06 11:27:04 +0000 |
commit | b514f411837be99b22d4df3a9b8e881a2021d087 (patch) | |
tree | 257e72f84151d465c997bf2f52ded888c7e72d64 /src/compiler/glsl/glcpp | |
parent | bc612536eb2f0f77725103e53077ad5a28036ac3 (diff) |
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 <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glcpp')
-rw-r--r-- | src/compiler/glsl/glcpp/glcpp-parse.y | 11 |
1 files changed, 7 insertions, 4 deletions
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; |