public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c: Fix up c_parser_has_attribute_expression [PR101176]
@ 2021-06-24 10:20 Jakub Jelinek
  2021-06-24 13:07 ` Marek Polacek
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2021-06-24 10:20 UTC (permalink / raw)
  To: Joseph S. Myers, Marek Polacek; +Cc: gcc-patches

Hi!

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.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

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.jj	2021-06-23 13:33:00.374434233 +0200
+++ gcc/c/c-parser.c	2021-06-23 23:53:45.146083923 +0200
@@ -8406,6 +8406,7 @@ c_parser_has_attribute_expression (c_par
 {
   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_par
 
   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_par
   else
     result.value =  boolean_false_node;
 
+  set_c_expr_source_range (&result, start, finish);
   return result;
 }
 

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c: Fix up c_parser_has_attribute_expression [PR101176]
  2021-06-24 10:20 [PATCH] c: Fix up c_parser_has_attribute_expression [PR101176] Jakub Jelinek
@ 2021-06-24 13:07 ` Marek Polacek
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Polacek @ 2021-06-24 13:07 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Joseph S. Myers, gcc-patches

On Thu, Jun 24, 2021 at 12:20:56PM +0200, Jakub Jelinek wrote:
> Hi!
> 
> 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.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok, thanks.
 
> 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.jj	2021-06-23 13:33:00.374434233 +0200
> +++ gcc/c/c-parser.c	2021-06-23 23:53:45.146083923 +0200
> @@ -8406,6 +8406,7 @@ c_parser_has_attribute_expression (c_par
>  {
>    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_par
>  
>    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_par
>    else
>      result.value =  boolean_false_node;
>  
> +  set_c_expr_source_range (&result, start, finish);
>    return result;
>  }

Marek


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-24 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 10:20 [PATCH] c: Fix up c_parser_has_attribute_expression [PR101176] Jakub Jelinek
2021-06-24 13:07 ` Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).