gimple.c (gimple_types_compatible_p_1): Compare record and union type members properly.
authorRichard Guenther <rguenther@suse.de>
Mon, 30 May 2011 14:55:03 +0000 (14:55 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 30 May 2011 14:55:03 +0000 (14:55 +0000)
2011-05-30  Richard Guenther  <rguenther@suse.de>

* gimple.c (gimple_types_compatible_p_1): Compare record
and union type members properly.

From-SVN: r174436

gcc/ChangeLog
gcc/gimple.c

index ed73069b2975feee52489f56c135f4060abe9e95..4a800f05b9b37454f334e246af02560ba08ea13e 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-30  Richard Guenther  <rguenther@suse.de>
+
+       * gimple.c (gimple_types_compatible_p_1): Compare record
+       and union type members properly.
+
 2011-05-30  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/49210
index e13b3ed7883c057f3c782992daadafc41e8031a8..0cbd443337befbd920579f1a9bd3a893af8c9d75 100644 (file)
@@ -3772,10 +3772,16 @@ gimple_types_compatible_p_1 (tree t1, tree t2, type_pair_t p,
             f1 && f2;
             f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
          {
-           /* The fields must have the same name, offset and type.  */
+           /* Different field kinds are not compatible.  */
+           if (TREE_CODE (f1) != TREE_CODE (f2))
+             goto different_types;
+           /* Field decls must have the same name and offset.  */
+           if (TREE_CODE (f1) == FIELD_DECL
+               && (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
+                   || !gimple_compare_field_offset (f1, f2)))
+             goto different_types;
+           /* All entities should have the same name and type.  */
            if (DECL_NAME (f1) != DECL_NAME (f2)
-               || DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
-               || !gimple_compare_field_offset (f1, f2)
                || !gtc_visit (TREE_TYPE (f1), TREE_TYPE (f2),
                               state, sccstack, sccstate, sccstate_obstack))
              goto different_types;