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 <jonathan@marek.ca> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
bc612536eb
commit
b514f41183
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue