diff mbox series

c: Fix up uninitialized next.original_type use in #embed optimization

Message ID Zw+u4L34EuqILj6D@tucnak
State New
Headers show
Series c: Fix up uninitialized next.original_type use in #embed optimization | expand

Commit Message

Jakub Jelinek Oct. 16, 2024, 12:17 p.m. UTC
Hi!

Jonathan pointed me at a diagnostic from an unnamed static analyzer
which found that next.original_type isn't initialized for the CPP_EMBED
case when it is parsed in a comma expression, yet
  expr.original_type = next.original_type;
is done a few lines later and the expr is returned.

Fixed thusly, tested on x86_64-linux, ok for trunk?

2024-10-16  Jakub Jelinek  <jakub@redhat.com>

	* c-parser.cc (c_parser_expression): Initialize next.original_type
	to integer_type_node for the CPP_EMBED case.


	Jakub

Comments

Joseph Myers Oct. 16, 2024, 3:11 p.m. UTC | #1
On Wed, 16 Oct 2024, Jakub Jelinek wrote:

> Hi!
> 
> Jonathan pointed me at a diagnostic from an unnamed static analyzer
> which found that next.original_type isn't initialized for the CPP_EMBED
> case when it is parsed in a comma expression, yet
>   expr.original_type = next.original_type;
> is done a few lines later and the expr is returned.
> 
> Fixed thusly, tested on x86_64-linux, ok for trunk?
> 
> 2024-10-16  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* c-parser.cc (c_parser_expression): Initialize next.original_type
> 	to integer_type_node for the CPP_EMBED case.

OK.
diff mbox series

Patch

--- gcc/c/c-parser.cc.jj	2024-10-16 10:32:27.000000000 +0200
+++ gcc/c/c-parser.cc	2024-10-16 14:09:44.393913829 +0200
@@ -13299,6 +13299,7 @@  c_parser_expression (c_parser *parser)
 	  next.value = build_int_cst (TREE_TYPE (val),
 				      ((const unsigned char *)
 				       RAW_DATA_POINTER (val))[last]);
+	  next.original_type = integer_type_node;
 	  c_parser_consume_token (parser);
 	}
       else