Hello, Dimitar, On Dec 22, 2024, Dimitar Dimitrov <dimi...@dinux.eu> wrote:
> On Sat, Dec 21, 2024 at 02:28:33AM -0300, Alexandre Oliva wrote: >> On Dec 20, 2024, Jakub Jelinek <ja...@redhat.com> wrote: >> >> > On Wed, Dec 18, 2024 at 12:59:11AM -0300, Alexandre Oliva wrote: >> >> * gcc.dg/field-merge-16.c: New. >> >> > Note the test FAILs on i686-linux or on x86_64-linux with -m32. >> >> Also fixed herein. Since the second patch adjusted one of the tests submitted in the first patch, I'm holding off from installing the second until the first one (URL below) is (hopefully) approved. https://gcc.gnu.org/pipermail/gcc-patches/2024-December/672161.html >> Regstrapped on x86_64-linux-gnu. I'd appreciate if someone who can test >> AVR and PRU would confirm that it fixes all field-merge-* failures. Ok >> to install? > All failures are now fixed for PRU: > make check-gcc-c RUNTESTFLAGS="--target_board=pru-sim > dg.exp=field-merge-*.c" > # of expected passes 36 Thanks! > But several failures remain for AVR: > FAIL: gcc.dg/field-merge-1.c (test for excess errors) > FAIL: gcc.dg/field-merge-1.c execution test [...] > I've attached the test log for AVR. Thanks, that was useful, if a little embarrasing (for my not realizing that narrower int types would require explicit truncation of wide constants ;-) > The tests seem to rely on int being at least 32 bits That reliance was accidental, rather than essential, so adding explicit casts should be enough to avoid warnings and runtime errors. Explicitly convert constants to the desired types, so as to not elicit warnings about implicit truncations, nor execution errors, on targets whose ints are narrower than 32 bits. Tested (on top of the previous patches) on x86_64-linux-gnu, and on avr-none, inspecting gcc.log and disregarding linker errors for not finding -lm and -lc. I'd appreciate confirmation about execution tests on avr (thanks in advance). Ok to install? for gcc/testsuite/ChangeLog PR testsuite/118025 * gcc.dg/field-merge-1.c: Convert constants to desired types. * gcc.dg/field-merge-3.c: Likewise. * gcc.dg/field-merge-4.c: Likewise. * gcc.dg/field-merge-5.c: Likewise. * gcc.dg/field-merge-11.c: Likewise. * gcc.dg/field-merge-17.c: Don't mess with padding bits. --- gcc/testsuite/gcc.dg/field-merge-1.c | 4 ++-- gcc/testsuite/gcc.dg/field-merge-11.c | 10 +++++++--- gcc/testsuite/gcc.dg/field-merge-17.c | 4 +++- gcc/testsuite/gcc.dg/field-merge-3.c | 4 ++-- gcc/testsuite/gcc.dg/field-merge-4.c | 6 +++--- gcc/testsuite/gcc.dg/field-merge-5.c | 6 +++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gcc/testsuite/gcc.dg/field-merge-1.c b/gcc/testsuite/gcc.dg/field-merge-1.c index 4405d40ee79d8..4e7f6ae9332a8 100644 --- a/gcc/testsuite/gcc.dg/field-merge-1.c +++ b/gcc/testsuite/gcc.dg/field-merge-1.c @@ -25,8 +25,8 @@ struct TB { unsigned char s; } __attribute__ ((packed, aligned (4), scalar_storage_order ("big-endian"))); -#define vc 0xaa -#define vi 0x12345678 +#define vc (unsigned char)0xaa +#define vi (unsigned int)0x12345678 struct TL vL = { vc, vi, vc, vi, vc, vi, vc }; struct TB vB = { vc, vi, vc, vi, vc, vi, vc }; diff --git a/gcc/testsuite/gcc.dg/field-merge-11.c b/gcc/testsuite/gcc.dg/field-merge-11.c index fe627cddd7fdf..9e606e3bef16a 100644 --- a/gcc/testsuite/gcc.dg/field-merge-11.c +++ b/gcc/testsuite/gcc.dg/field-merge-11.c @@ -10,7 +10,11 @@ struct s { int c; } __attribute__ ((aligned (4))); -struct s p = { 42, (short)(0xef1 - 0x1000), 0x12345678 }; +struct s p = { + (short)(unsigned short)42, + (short)(unsigned short)(0xef1 - 0x1000), + (int)(unsigned int)0x12345678 +}; void f (void) { if (0 @@ -19,9 +23,9 @@ void f (void) { || (int)(signed char)p.b != (int)(signed char)(0xef1 - 0x1000) || (unsigned)(unsigned char)p.b != (unsigned)(unsigned char)(0xef1 - 0x1000) || (unsigned)p.b != (unsigned short)(0xef1 - 0x1000) - || (int)(short)p.b != (int)(0xef1 - 0x1000) + || (int)(short)p.b != (int)(short)(unsigned short)(0xef1 - 0x1000) || (long)(unsigned char)(p.c >> 8) != (long)(unsigned char)0x123456 - || p.c != 0x12345678 + || p.c != (int)(unsigned int)0x12345678 ) __builtin_abort (); } diff --git a/gcc/testsuite/gcc.dg/field-merge-17.c b/gcc/testsuite/gcc.dg/field-merge-17.c index a42658ac5c516..35ead95406061 100644 --- a/gcc/testsuite/gcc.dg/field-merge-17.c +++ b/gcc/testsuite/gcc.dg/field-merge-17.c @@ -3,6 +3,8 @@ /* Check that we can optimize misaligned double-words. */ +#include <stddef.h> + struct s { short a; long long b; @@ -33,7 +35,7 @@ int main () { if (fp () > 0) __builtin_abort (); unsigned char *pc = (unsigned char *)&p; - for (int i = 0; i < sizeof (p); i++) + for (int i = 0; i < offsetof (struct s, e) + sizeof (p.e); i++) { pc[i] = 1; if (fp () < 0) diff --git a/gcc/testsuite/gcc.dg/field-merge-3.c b/gcc/testsuite/gcc.dg/field-merge-3.c index a9fe404fa4261..e9af4915ad8c1 100644 --- a/gcc/testsuite/gcc.dg/field-merge-3.c +++ b/gcc/testsuite/gcc.dg/field-merge-3.c @@ -15,8 +15,8 @@ struct T2 { unsigned int z; } __attribute__((__aligned__(8))); -#define vc 0xaa -#define vi 0x12345678 +#define vc (unsigned char)0xaa +#define vi (unsigned int)0x12345678 struct T1 v1 = { { vc + !BIG_ENDIAN_P, vc + BIG_ENDIAN_P }, vc, vi }; struct T2 v2 = { (vc << 8) | (vc - 1), vc, vi }; diff --git a/gcc/testsuite/gcc.dg/field-merge-4.c b/gcc/testsuite/gcc.dg/field-merge-4.c index c629069e52b2c..7c63123a282d3 100644 --- a/gcc/testsuite/gcc.dg/field-merge-4.c +++ b/gcc/testsuite/gcc.dg/field-merge-4.c @@ -18,9 +18,9 @@ struct T2 { unsigned int z; } __attribute__((__packed__, __aligned__(4))); -#define vc 0xaa -#define vs 0xccdd -#define vi 0x12345678 +#define vc (unsigned char)0xaa +#define vs (unsigned short)0xccdd +#define vi (unsigned int)0x12345678 struct T1 v1 = { -1, vc, 1, vs, vi }; struct T2 v2 = { -1, 0, vc, 1, vs, vi }; diff --git a/gcc/testsuite/gcc.dg/field-merge-5.c b/gcc/testsuite/gcc.dg/field-merge-5.c index 1580b14bcc935..1b5d1a8cb16e9 100644 --- a/gcc/testsuite/gcc.dg/field-merge-5.c +++ b/gcc/testsuite/gcc.dg/field-merge-5.c @@ -18,9 +18,9 @@ struct T2 { unsigned int z; } __attribute__((__packed__, __aligned__(8))); -#define vc 0xaa -#define vs 0xccdd -#define vi 0x12345678 +#define vc (unsigned char)0xaa +#define vs (unsigned short)0xccdd +#define vi (unsigned int)0x12345678 struct T1 v1 = { -1, vc, 1, vs, vi }; struct T2 v2 = { -1, 0, vc, 1, vs, vi }; -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive