]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c: Fix up c_parser_has_attribute_expression [PR101176]
authorJakub Jelinek <jakub@redhat.com>
Thu, 24 Jun 2021 13:58:02 +0000 (15:58 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 24 Jun 2021 13:58:02 +0000 (15:58 +0200)
This function keeps src_range member of the result uninitialized, which at
least under valgrind can show up later when those uninitialized location_t's
can make it into the IL or location_t hash tables.

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

PR c/101176
* c-parser.c (c_parser_has_attribute_expression): Set source range for
the result.

gcc/c/c-parser.c

index c0f702049bb3b2c8b0cff0b6d4220ac2c1924216..27034f88f4924b04b5ce09b01e52e839d5e1e11b 100644 (file)
@@ -8406,6 +8406,7 @@ c_parser_has_attribute_expression (c_parser *parser)
 {
   gcc_assert (c_parser_next_token_is_keyword (parser,
                                              RID_BUILTIN_HAS_ATTRIBUTE));
+  location_t start = c_parser_peek_token (parser)->location;
   c_parser_consume_token (parser);
 
   c_inhibit_evaluation_warnings++;
@@ -8484,6 +8485,7 @@ c_parser_has_attribute_expression (c_parser *parser)
 
   parser->translate_strings_p = save_translate_strings_p;
 
+  location_t finish = c_parser_peek_token (parser)->location;
   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
     c_parser_consume_token (parser);
   else
@@ -8512,6 +8514,7 @@ c_parser_has_attribute_expression (c_parser *parser)
   else
     result.value =  boolean_false_node;
 
+  set_c_expr_source_range (&result, start, finish);
   return result;
 }