From c2ca29d5a35f8dd62f76df48e16bbac7320660c8 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Wed, 7 Nov 2018 22:06:26 +0000 Subject: re PR c/87691 (transparent_union attribute does not work with MODE_PARTIAL_INT) 2018-11-07 Jozef Lawrynowicz 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 --- gcc/testsuite/ChangeLog | 9 +++++-- gcc/testsuite/gcc.target/msp430/pr87691.c | 41 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/msp430/pr87691.c (limited to 'gcc/testsuite') 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 +2018-11-07 Jozef Lawrynowicz - * gcc.dg/Wno-attribute-warning.c: New test. + PR c/87691 + * gcc.target/msp430/pr87691.c: New test. + +2018-11-07 Nikolai Merinov + + * gcc.dg/Wno-attribute-warning.c: New test. 2018-11-07 Nathan Sidwell 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; +} -- cgit v1.2.3