This commit is contained in:
Jakub Jelinek 2006-08-18 07:38:36 +00:00
parent 56455ee78d
commit 466a7f64bb
1 changed files with 92 additions and 0 deletions

92
gcc41-pr27898.patch Normal file
View File

@ -0,0 +1,92 @@
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
@@ -1126,11 +1126,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;
@@ -1157,28 +1158,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;