[PATCH] Fix PR36154, ICE in PTA
Richard Guenther
rguenther@suse.de
Wed May 7 22:36:00 GMT 2008
This fixes PR36154 where we take an address of a structure element
we don't assign a field for. Fixed thusly.
Bootstrapped and tested on x86_64-unknown-linux-gnu, I'll apply this
to trunk and the 4.3 branch tomorrow.
Richard.
2008-05-07 Richard Guenther <rguenther@suse.de>
PR middle-end/36154
* tree-ssa-structalias.c (push_fields_onto_fieldstack): Make
sure to create a representative for trailing arrays for PTA.
* gcc.c-torture/compile/pr36154.c: New testcase.
Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c (revision 135047)
--- tree-ssa-structalias.c (working copy)
*************** push_fields_onto_fieldstack (tree type,
*** 4180,4190 ****
(DECL_NONADDRESSABLE_P (field)
? addressable_type
: TREE_TYPE (field))))
! && DECL_SIZE (field)
! && !integer_zerop (DECL_SIZE (field)))
! /* Empty structures may have actual size, like in C++. So
see if we didn't push any subfields and the size is
! nonzero, push the field onto the stack */
push = true;
if (push)
--- 4180,4194 ----
(DECL_NONADDRESSABLE_P (field)
? addressable_type
: TREE_TYPE (field))))
! && ((DECL_SIZE (field)
! && !integer_zerop (DECL_SIZE (field)))
! || (!DECL_SIZE (field)
! && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)))
! /* Empty structures may have actual size, like in C++. So
see if we didn't push any subfields and the size is
! nonzero, push the field onto the stack. Trailing flexible
! array members also need a representative to be able to
! treat taking their address in PTA. */
push = true;
if (push)
Index: testsuite/gcc.c-torture/compile/pr36154.c
===================================================================
*** testsuite/gcc.c-torture/compile/pr36154.c (revision 0)
--- testsuite/gcc.c-torture/compile/pr36154.c (revision 0)
***************
*** 0 ****
--- 1,11 ----
+ struct eth_test_pkt {
+ unsigned short len;
+ unsigned short ctr;
+ unsigned char packet[];
+ } __attribute__ ((packed));
+ struct eth_test_pkt pkt_unaligned = { .packet = { 0xFC } };
+ int cmd_unaligned(const void *p)
+ {
+ return memcmp(p, pkt_unaligned.packet, 1);
+ }
+
More information about the Gcc-patches
mailing list