summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-19 23:26:14 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-19 23:26:14 +0000
commitaedd6e32f3fcdbfa020abaa7370a9818c80f934c (patch)
tree3a1029b66d21f2d28e973b73a24decf8050a2d9a
parent3d8785bcc7373fb8f4c3bfd46a96ded7aa2c2818 (diff)
downloadppe42-gcc-aedd6e32f3fcdbfa020abaa7370a9818c80f934c.tar.gz
ppe42-gcc-aedd6e32f3fcdbfa020abaa7370a9818c80f934c.zip
PR c/30762
* c-typeck.c (convert_for_assignment): Call comptypes for RECORD_TYPE or UNION_TYPE. * gcc.dg/pr30762-1.c: New test. * gcc.dg/pr30762-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123073 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/c-typeck.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/pr30762-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/pr30762-2.c9
5 files changed, 40 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc56f6d6c9f..849ab904555 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2007-03-20 Jakub Jelinek <jakub@redhat.com>
+ PR c/30762
+ * c-typeck.c (convert_for_assignment): Call comptypes for
+ RECORD_TYPE or UNION_TYPE.
+
PR inline-asm/30505
* reload1.c (reload): Do invalid ASM checking after
cleanup_subreg_operands.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 6986405e8a9..5976cb26309 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -3896,10 +3896,16 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
|| coder == BOOLEAN_TYPE))
return convert_and_check (type, rhs);
+ /* Aggregates in different TUs might need conversion. */
+ if ((codel == RECORD_TYPE || codel == UNION_TYPE)
+ && codel == coder
+ && comptypes (type, rhstype))
+ return convert_and_check (type, rhs);
+
/* Conversion to a transparent union from its member types.
This applies only to function arguments. */
- else if (codel == UNION_TYPE && TYPE_TRANSPARENT_UNION (type)
- && (errtype == ic_argpass || errtype == ic_argpass_nonproto))
+ if (codel == UNION_TYPE && TYPE_TRANSPARENT_UNION (type)
+ && (errtype == ic_argpass || errtype == ic_argpass_nonproto))
{
tree memb, marginal_memb = NULL_TREE;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9a6607f2d11..0e772e49a86 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2007-03-20 Jakub Jelinek <jakub@redhat.com>
+ PR c/30762
+ * gcc.dg/pr30762-1.c: New test.
+ * gcc.dg/pr30762-2.c: New test.
+
PR inline-asm/30505
* gcc.target/i386/pr30505.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr30762-1.c b/gcc/testsuite/gcc.dg/pr30762-1.c
new file mode 100644
index 00000000000..97dca8c020e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr30762-1.c
@@ -0,0 +1,15 @@
+/* PR c/30762 */
+/* { dg-do compile } */
+/* { dg-options "--combine -O3" } */
+/* { dg-additional-sources pr30762-2.c } */
+
+typedef struct { int i; } D;
+extern void foo (D);
+
+void
+bar (void)
+{
+ D d;
+ d.i = 1;
+ foo (d);
+}
diff --git a/gcc/testsuite/gcc.dg/pr30762-2.c b/gcc/testsuite/gcc.dg/pr30762-2.c
new file mode 100644
index 00000000000..7e914ebfa86
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr30762-2.c
@@ -0,0 +1,9 @@
+/* PR c/30762 */
+/* { dg-do compile } */
+
+typedef struct { int i; } D;
+
+void
+foo (D x)
+{
+}
OpenPOWER on IntegriCloud