Commit e6e61607 by Richard Biener

lto/94822 - fix ICE in component_ref_size

This ICE appears because gcc will stream it to the function_body section
when processing the variable with the initial value of the constructor
type, and the error_mark_node to the decls section.
When recompiling, the value obtained with DECL_INITIAL will be error_mark.

2020-04-29  Richard Biener  <rguenther@suse.de>
	    Li Zekun  <lizekun1@huawei.com>

	PR lto/94822
	* tree.c (component_ref_size): Guard against error_mark_node
	DECL_INITIAL as it happens with LTO.

	* gcc.dg/lto/pr94822_0.c: New testcase.
	* gcc.dg/lto/pr94822_1.c: Alternate file.
	* gcc.dg/lto/pr94822.h: Likewise.
parent 56fe3ca3
2020-04-29 Richard Biener <rguenther@suse.de>
Li Zekun <lizekun1@huawei.com>
PR lto/94822
* tree.c (component_ref_size): Guard against error_mark_node
DECL_INITIAL as it happens with LTO.
2020-04-29 Richard Sandiford <richard.sandiford@arm.com> 2020-04-29 Richard Sandiford <richard.sandiford@arm.com>
* config/aarch64/aarch64.c (aarch64_function_arg_alignment): Add a * config/aarch64/aarch64.c (aarch64_function_arg_alignment): Add a
......
2020-04-29 Richard Biener <rguenther@suse.de>
Li Zekun <lizekun1@huawei.com>
PR lto/94822
* gcc.dg/lto/pr94822_0.c: New testcase.
* gcc.dg/lto/pr94822_1.c: Alternate file.
* gcc.dg/lto/pr94822.h: Likewise.
2020-04-29 Richard Sandiford <richard.sandiford@arm.com> 2020-04-29 Richard Sandiford <richard.sandiford@arm.com>
* g++.target/aarch64/no_unique_address_1.C: New test. * g++.target/aarch64/no_unique_address_1.C: New test.
......
typedef struct {
int i;
int ints[];
} struct_t;
/* { dg-lto-do link } */
#include "pr94822.h"
extern struct_t my_struct;
int main() {
return my_struct.ints[1];
}
#include "pr94822.h"
struct_t my_struct = {
20,
{ 1, 2 }
};
...@@ -13723,24 +13723,25 @@ component_ref_size (tree ref, bool *interior_zero_length /* = NULL */) ...@@ -13723,24 +13723,25 @@ component_ref_size (tree ref, bool *interior_zero_length /* = NULL */)
/* MEMBER is a true flexible array member. Compute its size from /* MEMBER is a true flexible array member. Compute its size from
the initializer of the BASE object if it has one. */ the initializer of the BASE object if it has one. */
if (tree init = DECL_P (base) ? DECL_INITIAL (base) : NULL_TREE) if (tree init = DECL_P (base) ? DECL_INITIAL (base) : NULL_TREE)
{ if (init != error_mark_node)
init = get_initializer_for (init, member); {
if (init) init = get_initializer_for (init, member);
{ if (init)
memsize = TYPE_SIZE_UNIT (TREE_TYPE (init)); {
if (tree refsize = TYPE_SIZE_UNIT (reftype)) memsize = TYPE_SIZE_UNIT (TREE_TYPE (init));
{ if (tree refsize = TYPE_SIZE_UNIT (reftype))
/* Use the larger of the initializer size and the tail {
padding in the enclosing struct. */ /* Use the larger of the initializer size and the tail
poly_int64 rsz = tree_to_poly_int64 (refsize); padding in the enclosing struct. */
rsz -= baseoff; poly_int64 rsz = tree_to_poly_int64 (refsize);
if (known_lt (tree_to_poly_int64 (memsize), rsz)) rsz -= baseoff;
memsize = wide_int_to_tree (TREE_TYPE (memsize), rsz); if (known_lt (tree_to_poly_int64 (memsize), rsz))
} memsize = wide_int_to_tree (TREE_TYPE (memsize), rsz);
}
baseoff = 0; baseoff = 0;
} }
} }
if (!memsize) if (!memsize)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment