93 lines
2.3 KiB
Diff
93 lines
2.3 KiB
Diff
2006-07-06 Alexandre Oliva <aoliva@redhat.com>
|
|
|
|
PR c/27898
|
|
* c-typeck.c (tagged_types_tu_compatible_p): Enable exact
|
|
matches between anonymous union fields.
|
|
|
|
2006-08-18 Jakub Jelinek <jakub@redhat.com>
|
|
|
|
PR c/27898
|
|
* gcc.dg/pr27898.c: New test.
|
|
|
|
--- gcc/testsuite/gcc.dg/pr27898.c.jj 2006-08-18 09:19:33.000000000 +0200
|
|
+++ gcc/testsuite/gcc.dg/pr27898.c 2006-08-18 09:19:27.000000000 +0200
|
|
@@ -0,0 +1,8 @@
|
|
+/* PR c/27898 */
|
|
+/* { dg-do compile } */
|
|
+/* { dg-options "--combine" } */
|
|
+/* { dg-additional-sources "pr27898.c" } */
|
|
+
|
|
+union u { struct { int i; }; };
|
|
+
|
|
+extern int foo (union u *);
|
|
--- gcc/c-typeck.c.jj 2006-08-17 09:55:11.000000000 +0200
|
|
+++ gcc/c-typeck.c 2006-08-18 09:14:15.000000000 +0200
|
|
@@ -1072,11 +1072,12 @@ tagged_types_tu_compatible_p (tree t1, t
|
|
{
|
|
int result;
|
|
|
|
-
|
|
- if (DECL_NAME (s1) == NULL
|
|
- || DECL_NAME (s1) != DECL_NAME (s2))
|
|
+ if (DECL_NAME (s1) != DECL_NAME (s2))
|
|
break;
|
|
result = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2));
|
|
+
|
|
+ if (result != 1 && !DECL_NAME (s1))
|
|
+ break;
|
|
if (result == 0)
|
|
{
|
|
tu->val = 0;
|
|
@@ -1103,28 +1104,31 @@ tagged_types_tu_compatible_p (tree t1, t
|
|
{
|
|
bool ok = false;
|
|
|
|
- if (DECL_NAME (s1) != NULL)
|
|
- for (s2 = TYPE_FIELDS (t2); s2; s2 = TREE_CHAIN (s2))
|
|
- if (DECL_NAME (s1) == DECL_NAME (s2))
|
|
- {
|
|
- int result;
|
|
- result = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2));
|
|
- if (result == 0)
|
|
- {
|
|
- tu->val = 0;
|
|
- return 0;
|
|
- }
|
|
- if (result == 2)
|
|
- needs_warning = true;
|
|
-
|
|
- if (TREE_CODE (s1) == FIELD_DECL
|
|
- && simple_cst_equal (DECL_FIELD_BIT_OFFSET (s1),
|
|
- DECL_FIELD_BIT_OFFSET (s2)) != 1)
|
|
- break;
|
|
+ for (s2 = TYPE_FIELDS (t2); s2; s2 = TREE_CHAIN (s2))
|
|
+ if (DECL_NAME (s1) == DECL_NAME (s2))
|
|
+ {
|
|
+ int result;
|
|
+
|
|
+ result = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2));
|
|
|
|
- ok = true;
|
|
+ if (result != 1 && !DECL_NAME (s1))
|
|
+ continue;
|
|
+ if (result == 0)
|
|
+ {
|
|
+ tu->val = 0;
|
|
+ return 0;
|
|
+ }
|
|
+ if (result == 2)
|
|
+ needs_warning = true;
|
|
+
|
|
+ if (TREE_CODE (s1) == FIELD_DECL
|
|
+ && simple_cst_equal (DECL_FIELD_BIT_OFFSET (s1),
|
|
+ DECL_FIELD_BIT_OFFSET (s2)) != 1)
|
|
break;
|
|
- }
|
|
+
|
|
+ ok = true;
|
|
+ break;
|
|
+ }
|
|
if (!ok)
|
|
{
|
|
tu->val = 0;
|