re PR middle-end/36154 (internal compiler error: in get_constraint_for_component_ref...
authorRichard Guenther <rguenther@suse.de>
Thu, 8 May 2008 08:20:45 +0000 (08:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 8 May 2008 08:20:45 +0000 (08:20 +0000)
2008-05-08  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.

From-SVN: r135071

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr36154.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index bdc484612ddfcac3bcdb575c83cf7b18cf4b0c92..1121be1a9e053961afe10f591362c80256b021ea 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-08  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.
+
 2008-05-08  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/36172
index 68626fdf2f1a28eeac069f456f288b79ec12375e..2b137fa9988ea8a1872572d44e2ccf362efe4880 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-08  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36154
+       * gcc.c-torture/compile/pr36154.c: New testcase.
+
 2008-05-08  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/36172
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr36154.c b/gcc/testsuite/gcc.c-torture/compile/pr36154.c
new file mode 100644 (file)
index 0000000..ae3eb83
--- /dev/null
@@ -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);
+}
+
index ddcf4982690dae9be710bbe058f8de08dc475cd6..d58478ebeb29591a4818d8b8eb07caf3d327afff 100644 (file)
@@ -4160,11 +4160,15 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
                        (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
+                    && ((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 */
+                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)