aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-23 07:15:37 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-23 07:15:37 +0000
commit9369a09f9c4ae34d6fdc31ba67fe91d2a8cc9bbc (patch)
tree23d01a3bd7d49c49d7f4b60bd073b43567826b34
parente693d7f1bd565ae51674ee0a1cd8faa8011d4836 (diff)
PR c/28706
PR c/28712 * tree.c (merge_attributes, attribute_list_contained): If both TREE_VALUEs are TREE_LISTs, use simple_cst_list_equal instead of simple_cst_equal. * c-typeck.c (comptypes_internal): Don't consider aggregates in different TUs as compatible if there one set of attributes is not a subset of the other type's attributes. (composite_type): Try harder not to create a new aggregate type. * gcc.dg/pr28706.c: New test. * gcc.dg/pr28712.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117167 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-typeck.c20
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/pr28706.c12
-rw-r--r--gcc/testsuite/gcc.dg/pr28712.c16
-rw-r--r--gcc/tree.c26
6 files changed, 89 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0b0ef57d94e..a62e378d102 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2006-09-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/28706
+ PR c/28712
+ * tree.c (merge_attributes, attribute_list_contained): If both
+ TREE_VALUEs are TREE_LISTs, use simple_cst_list_equal instead of
+ simple_cst_equal.
+ * c-typeck.c (comptypes_internal): Don't consider aggregates
+ in different TUs as compatible if there one set of attributes is
+ not a subset of the other type's attributes.
+ (composite_type): Try harder not to create a new aggregate type.
+
2006-09-22 Geoffrey Keating <geoffk@apple.com>
* config/i386/driver-i386.c: Always define host_detect_local_cpu.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 42e01d2af52..00537ac3f4c 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -375,6 +375,19 @@ composite_type (tree t1, tree t2)
return build_type_attribute_variant (t1, attributes);
}
+ case ENUMERAL_TYPE:
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ if (attributes != NULL)
+ {
+ /* Try harder not to create a new aggregate type. */
+ if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
+ return t1;
+ if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
+ return t2;
+ }
+ return build_type_attribute_variant (t1, attributes);
+
case FUNCTION_TYPE:
/* Function types: prefer the one that specified arg types.
If both do, merge the arg types. Also merge the return types. */
@@ -891,6 +904,13 @@ comptypes_internal (tree type1, tree type2)
case UNION_TYPE:
if (val != 1 && !same_translation_unit_p (t1, t2))
{
+ tree a1 = TYPE_ATTRIBUTES (t1);
+ tree a2 = TYPE_ATTRIBUTES (t2);
+
+ if (! attribute_list_contained (a1, a2)
+ && ! attribute_list_contained (a2, a1))
+ break;
+
if (attrval != 2)
return tagged_types_tu_compatible_p (t1, t2);
val = tagged_types_tu_compatible_p (t1, t2);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 55a77b43d4f..e6c4a117b31 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/28706
+ * gcc.dg/pr28706.c: New test.
+
+ PR c/28712
+ * gcc.dg/pr28712.c: New test.
+
2006-09-22 Mike Stump <mrs@apple.com>
* obj-c++.dg/encode-3.mm: Fix for 64-bit support.
diff --git a/gcc/testsuite/gcc.dg/pr28706.c b/gcc/testsuite/gcc.dg/pr28706.c
new file mode 100644
index 00000000000..4c185af4123
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr28706.c
@@ -0,0 +1,12 @@
+/* PR c/28706 */
+/* { dg-do compile } */
+/* { dg-options "--combine" } */
+/* { dg-additional-sources "pr28706.c" } */
+
+struct A
+{
+ int i;
+} __attribute__((aligned (sizeof (long int))));
+
+extern void foo (struct A *);
+extern void foo (struct A *);
diff --git a/gcc/testsuite/gcc.dg/pr28712.c b/gcc/testsuite/gcc.dg/pr28712.c
new file mode 100644
index 00000000000..0bbb45314cf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr28712.c
@@ -0,0 +1,16 @@
+/* PR c/28712 */
+/* { dg-do compile } */
+/* { dg-options "--combine" } */
+/* { dg-additional-sources "pr28712.c pr28712.c" } */
+
+struct A;
+
+extern struct A *a;
+
+struct A { } __attribute__((packed));
+
+struct B __attribute__((aligned (sizeof (int))));
+
+extern struct B *b;
+
+struct B { int i; } __attribute__((packed));
diff --git a/gcc/tree.c b/gcc/tree.c
index a58c3274c4b..cfbfe1462b6 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3554,7 +3554,17 @@ merge_attributes (tree a1, tree a2)
a = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
TREE_CHAIN (a)))
{
- if (simple_cst_equal (TREE_VALUE (a), TREE_VALUE (a2)) == 1)
+ if (TREE_VALUE (a) != NULL
+ && TREE_CODE (TREE_VALUE (a)) == TREE_LIST
+ && TREE_VALUE (a2) != NULL
+ && TREE_CODE (TREE_VALUE (a2)) == TREE_LIST)
+ {
+ if (simple_cst_list_equal (TREE_VALUE (a),
+ TREE_VALUE (a2)) == 1)
+ break;
+ }
+ else if (simple_cst_equal (TREE_VALUE (a),
+ TREE_VALUE (a2)) == 1)
break;
}
if (a == NULL_TREE)
@@ -4374,15 +4384,21 @@ attribute_list_contained (tree l1, tree l2)
attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)),
TREE_CHAIN (attr)))
{
- if (simple_cst_equal (TREE_VALUE (t2), TREE_VALUE (attr)) == 1)
+ if (TREE_VALUE (t2) != NULL
+ && TREE_CODE (TREE_VALUE (t2)) == TREE_LIST
+ && TREE_VALUE (attr) != NULL
+ && TREE_CODE (TREE_VALUE (attr)) == TREE_LIST)
+ {
+ if (simple_cst_list_equal (TREE_VALUE (t2),
+ TREE_VALUE (attr)) == 1)
+ break;
+ }
+ else if (simple_cst_equal (TREE_VALUE (t2), TREE_VALUE (attr)) == 1)
break;
}
if (attr == 0)
return 0;
-
- if (simple_cst_equal (TREE_VALUE (t2), TREE_VALUE (attr)) != 1)
- return 0;
}
return 1;