aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJozef Lawrynowicz <jozefl@gcc.gnu.org>2018-11-07 22:06:26 +0000
committerJozef Lawrynowicz <jozefl@gcc.gnu.org>2018-11-07 22:06:26 +0000
commitc2ca29d5a35f8dd62f76df48e16bbac7320660c8 (patch)
tree1ca8080d96fb6d191045c84771064ac19c0dd628 /gcc/testsuite
parente217792beda1ca48daea497c00694a3924f992c5 (diff)
re PR c/87691 (transparent_union attribute does not work with MODE_PARTIAL_INT)
2018-11-07 Jozef Lawrynowicz <jozef.l@mittosystems.com> PR c/87691 gcc/ChangeLog: * stor-layout.c (compute_record_mode): Set TYPE_MODE of UNION_TYPE to the mode of the widest field iff the widest field has mode class MODE_INT, or MODE_PARTIAL_INT and the union would be passed by reference. gcc/testsuite/ChangeLog: * gcc.target/msp430/pr87691.c: New test. From-SVN: r265894
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.target/msp430/pr87691.c41
2 files changed, 48 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 689d7a7f11b..51f1b6085f8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,11 @@
-2018-11-17 Nikolai Merinov <n.merinov@inango-systems.com>
+2018-11-07 Jozef Lawrynowicz <jozef.l@mittosystems.com>
- * gcc.dg/Wno-attribute-warning.c: New test.
+ PR c/87691
+ * gcc.target/msp430/pr87691.c: New test.
+
+2018-11-07 Nikolai Merinov <n.merinov@inango-systems.com>
+
+ * gcc.dg/Wno-attribute-warning.c: New test.
2018-11-07 Nathan Sidwell <nathan@acm.org>
diff --git a/gcc/testsuite/gcc.target/msp430/pr87691.c b/gcc/testsuite/gcc.target/msp430/pr87691.c
new file mode 100644
index 00000000000..c00425d2452
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr87691.c
@@ -0,0 +1,41 @@
+/* PR 87691 - Test that a union containing __int20 and a float is not treated as
+ 20-bits in size. */
+
+/* { dg-do compile } */
+/* { dg-skip-if "no __int20 for mcpu=msp430" { *-*-* } { "-mcpu=msp430" } { "" } } */
+/* { dg-final { scan-assembler-not "MOVX.A" } } */
+
+/* To move a 20-bit value from memory (using indexed or indirect register
+ mode), onto the stack (also addressed using indexed or indirect register
+ mode), MOVX.A must be used. MOVA does not support these addressing modes.
+ Therefore, to check that the union is not manipulated as a 20-bit type,
+ test that no MOVX.A instructions are present in the assembly.
+
+ MOVA is used to fill/spill u.i, but if the union is treated as 20 bits in
+ size, MOVX.A would be used. No other __int20 operations are present
+ in the source, so there will be no valid uses of MOVX.A in the resulting
+ assembly. */
+
+union U1
+{
+ float f;
+ __int20 i;
+};
+
+union U2
+{
+ __int20 i;
+ float f;
+};
+
+float foo1 (union U1 u)
+{
+ u.i += 42;
+ return u.f;
+}
+
+float foo2 (union U2 u)
+{
+ u.i += 42;
+ return u.f;
+}