Re: [PATCH] TESTSUITE: Fix tests for 16-bit targets

2020-05-20 Thread Jozef Lawrynowicz
On Wed, May 20, 2020 at 03:37:30PM +0200, Christophe Lyon via Gcc-patches wrote:
> Hi,
> 
> 
> 
> On Mon, 18 May 2020 at 14:42, Jozef Lawrynowicz
>  wrote:
> >
> > On Fri, May 15, 2020 at 10:48:56PM +, Joseph Myers wrote:
> > > On Fri, 15 May 2020, Jozef Lawrynowicz wrote:
> > >
> > > > The attached patch fixes many GCC and G++ tests for 16-bit targets. 
> > > > These
> > > > targets can have the following properties:
> > > > - "int", "size_t", "ptrdiff_t", "void *" are 16-bit types
> > > > - sizeof(int) == sizeof(short)
> > >
> > > Some of the tests are disabled by the patch for the case where pointers
> > > are the same size as int.  Were those tests all previously failing for
> > > 32-bit targets where that's the case?  If not, ptr_eq_int seems an
> > > inappropriate condition for disabling them.
> >
> > Ah yes, regarding g++.dg/init/new44.C, it seems that i386-pc-linux-gnu
> > does require an array size cookie even though ptr_eq_int (in fact,
> > since the decision relates to size_t, a pointer size effective target 
> > shouldn't
> > have been used anyway). I'll amend the condition so it is skipped for msp430
> > only.
> >
> > The other test using ptr_eq_int (g++.dg/init/const7.C) is also passing
> > on i386-pc-linux-gnu, so I'll amend that as well.
> >
> > I'll make sure to do a full regtest on i386-pc-linux-gnu before
> > applying.
> >
> 
> I've noticed regressions on aarch64 with -mabi=ilp32:
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++14  (test for warnings, line 
> 37)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++14  (test for warnings, line 
> 60)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++17  (test for warnings, line 
> 37)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++17  (test for warnings, line 
> 60)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++2a  (test for warnings, line 
> 37)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++2a  (test for warnings, line 
> 60)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++98  (test for warnings, line 
> 37)
> g++.dg/warn/Wconversion-null-2.C  -std=gnu++98  (test for warnings, line 
> 60)
> 
> The logs say:
> /gcc/testsuite/g++.dg/warn/Wconversion-null-2.C:37:9: error: call of
> overloaded 'g(NULL)' is ambiguous
> /gcc/testsuite/g++.dg/warn/Wconversion-null-2.C:60:11: error: call of
> overloaded 'g(NULL)' is ambiguous
> 
> Can you check/fix?

Hmm, it seems that when performing overload resolution, the compiler considers
g(long) and g(void*) equally viable candidates for g(NULL) and so the
ambiguous error occurs. Even though
sizeof(int) == sizeof(long) == sizeof(void*), the g(int) candidate is more
viable than the others for g(NULL) so is required to break the tie between
g(long) and g(void*).

The problem for msp430/-mlarge is that the bitsize of a pointer is 20-bits and
that doesn't match any of the g() declarations using integral types for
arguments. So the reason I originally changed the test is because all of the g()
declarations are considered equally viable and so the g(NULL) call was reported
as ambiguous.

I've committed the attached patch which reverts the changes to the
Wconversion-null* tests and adds a special case for __MSP430X_LARGE__.

Jozef
> 
> Thanks
> 
> Christophe
> 
> > Thanks,
> > Jozef
> >
> > >
> > > --
> > > Joseph S. Myers
> > > jos...@codesourcery.com
>From edd482f310f4ec46310e7c2c82c88dad64b5a4ff Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz 
Date: Wed, 20 May 2020 22:15:18 +0100
Subject: [PATCH] TESTSUITE: Fix Wconversion-null*.C tests for aarch64
 -mabi=ilp32

This fixes regressions for aarch64 with -mabi=ilp32 of the
Wconversion-null*.C tests, introduced by 92ea8e1bccc.

The "g (int)" declaration is required for that target where
sizeof(int) == sizeof(long) == sizeof(void *).

To handle the msp430/-mlarge case, an explicit declaration of
"g (__int20)" is required.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wconversion-null-2.C: Add explicit declarations for l()
and g() with int, long, long long and __int20 arguments.
* g++.dg/warn/Wconversion-null.C: Likewise.
---
 .../g++.dg/warn/Wconversion-null-2.C  | 20 +--
 gcc/testsuite/g++.dg/warn/Wconversion-null.C  | 20 +--
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C 
b/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C
index 0f5bf58bd5d..3ba756e596b 100644
--- a/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C
+++ b/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C
@@ -3,7 +3,12 @@
 
 #include 
 
-void g(__INTPTR_TYPE__) {}
+void g(int) {}
+void g(long) {}
+void g(long long) {}
+#ifdef __MSP430X_LARGE__
+void g(__int20) {}
+#endif
 extern void g(void*);
 
 template 
@@ -15,7 +20,18 @@ template 
 void l(T);
 
 template <>
-void l(__INTPTR_TYPE__) {}
+void l(int) {}
+
+template <>
+void l(long) {}
+
+template <>
+void l(long long) {}
+
+#ifdef __MSP430X_LARGE__
+template <>
+void l(__int20) {}
+#endif
 
 void 

Re: [PATCH] TESTSUITE: Fix tests for 16-bit targets

2020-05-20 Thread Christophe Lyon via Gcc-patches
Hi,



On Mon, 18 May 2020 at 14:42, Jozef Lawrynowicz
 wrote:
>
> On Fri, May 15, 2020 at 10:48:56PM +, Joseph Myers wrote:
> > On Fri, 15 May 2020, Jozef Lawrynowicz wrote:
> >
> > > The attached patch fixes many GCC and G++ tests for 16-bit targets. These
> > > targets can have the following properties:
> > > - "int", "size_t", "ptrdiff_t", "void *" are 16-bit types
> > > - sizeof(int) == sizeof(short)
> >
> > Some of the tests are disabled by the patch for the case where pointers
> > are the same size as int.  Were those tests all previously failing for
> > 32-bit targets where that's the case?  If not, ptr_eq_int seems an
> > inappropriate condition for disabling them.
>
> Ah yes, regarding g++.dg/init/new44.C, it seems that i386-pc-linux-gnu
> does require an array size cookie even though ptr_eq_int (in fact,
> since the decision relates to size_t, a pointer size effective target 
> shouldn't
> have been used anyway). I'll amend the condition so it is skipped for msp430
> only.
>
> The other test using ptr_eq_int (g++.dg/init/const7.C) is also passing
> on i386-pc-linux-gnu, so I'll amend that as well.
>
> I'll make sure to do a full regtest on i386-pc-linux-gnu before
> applying.
>

I've noticed regressions on aarch64 with -mabi=ilp32:
g++.dg/warn/Wconversion-null-2.C  -std=gnu++14  (test for warnings, line 37)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++14  (test for warnings, line 60)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++17  (test for warnings, line 37)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++17  (test for warnings, line 60)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++2a  (test for warnings, line 37)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++2a  (test for warnings, line 60)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++98  (test for warnings, line 37)
g++.dg/warn/Wconversion-null-2.C  -std=gnu++98  (test for warnings, line 60)

The logs say:
/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C:37:9: error: call of
overloaded 'g(NULL)' is ambiguous
/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C:60:11: error: call of
overloaded 'g(NULL)' is ambiguous

Can you check/fix?

Thanks

Christophe

> Thanks,
> Jozef
>
> >
> > --
> > Joseph S. Myers
> > jos...@codesourcery.com


Re: [PATCH] TESTSUITE: Fix tests for 16-bit targets

2020-05-18 Thread Jozef Lawrynowicz
On Fri, May 15, 2020 at 10:48:56PM +, Joseph Myers wrote:
> On Fri, 15 May 2020, Jozef Lawrynowicz wrote:
> 
> > The attached patch fixes many GCC and G++ tests for 16-bit targets. These
> > targets can have the following properties:
> > - "int", "size_t", "ptrdiff_t", "void *" are 16-bit types
> > - sizeof(int) == sizeof(short)
> 
> Some of the tests are disabled by the patch for the case where pointers 
> are the same size as int.  Were those tests all previously failing for 
> 32-bit targets where that's the case?  If not, ptr_eq_int seems an 
> inappropriate condition for disabling them.

Ah yes, regarding g++.dg/init/new44.C, it seems that i386-pc-linux-gnu
does require an array size cookie even though ptr_eq_int (in fact,
since the decision relates to size_t, a pointer size effective target shouldn't
have been used anyway). I'll amend the condition so it is skipped for msp430
only.

The other test using ptr_eq_int (g++.dg/init/const7.C) is also passing
on i386-pc-linux-gnu, so I'll amend that as well.

I'll make sure to do a full regtest on i386-pc-linux-gnu before
applying.

Thanks,
Jozef

> 
> -- 
> Joseph S. Myers
> jos...@codesourcery.com


Re: [PATCH] TESTSUITE: Fix tests for 16-bit targets

2020-05-15 Thread Joseph Myers
On Fri, 15 May 2020, Jozef Lawrynowicz wrote:

> The attached patch fixes many GCC and G++ tests for 16-bit targets. These
> targets can have the following properties:
> - "int", "size_t", "ptrdiff_t", "void *" are 16-bit types
> - sizeof(int) == sizeof(short)

Some of the tests are disabled by the patch for the case where pointers 
are the same size as int.  Were those tests all previously failing for 
32-bit targets where that's the case?  If not, ptr_eq_int seems an 
inappropriate condition for disabling them.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] TESTSUITE: Fix tests for 16-bit targets

2020-05-15 Thread Jeff Law via Gcc-patches
On Fri, 2020-05-15 at 18:26 +0100, Jozef Lawrynowicz wrote:
> The attached patch fixes many GCC and G++ tests for 16-bit targets. These
> targets can have the following properties:
> - "int", "size_t", "ptrdiff_t", "void *" are 16-bit types
> - sizeof(int) == sizeof(short)
> 
> These properties cause problems for a number of tests in the testsuite,
> where int is often assumed to be a 32-bit type (and the test relies on that
> property to run as expected or to not generate any unexpected warnings).
> Other failures occur when arrays larger than what is supported for 16-bit
> targets are declared, or the "short" type is expected to be smaller than 
> "int".
> 
> The fixes fall into a few different categories:
> - Explicitly defining a 32-bit int type and using that in place of "int" or
>   "unsigned int".
> - Skipping tests which rely on arrays sized larger than what is supported by
> the
>   target.
> - Adding or adjusting dg-{warning,error} directives
> - Other testcase specific adjustments.
> 
> I've successfully regtested the patch on x86_64-pc-linux-gnu and msp430-elf in
> the default, -mlarge and -mcpu=msp430 configurations.
> 
> There are no absolute changes to testresults on x86_64-pc-linux-gnu, but
> because
> of changes to the line number of dg-{warning,message,error,etc} directives, 
> the
> results comparison shows:
> UNTESTED->FAIL: 8 tests
> UNTESTED->PASS: 986 tests
> PASS->UNTESTED: 986 tests
> FAIL->UNTESTED: 8 tests
> 
> Across the 3 configurations for msp430, the total is:
> PASS->FAIL: 0 tests
> FAIL->PASS: 1108 tests
> UNTESTED->FAIL: 24 tests
> UNTESTED->PASS: 2924 tests
> FAIL->UNTESTED: 807 tests
> PASS->UNTESTED: 2564 tests
> 
> Ok for trunk?
> 
> What about for gcc-10 branch? It would be nice to clean up the testresults for
> MSP430, but I understand if it is undesirable to cause these line number
> changes
> to appear on the stable branch.
OK for the trunk.  I suspect the release managers wouldn't want it for the 
branch
though.  

jeff



[PATCH] TESTSUITE: Fix tests for 16-bit targets

2020-05-15 Thread Jozef Lawrynowicz
The attached patch fixes many GCC and G++ tests for 16-bit targets. These
targets can have the following properties:
- "int", "size_t", "ptrdiff_t", "void *" are 16-bit types
- sizeof(int) == sizeof(short)

These properties cause problems for a number of tests in the testsuite,
where int is often assumed to be a 32-bit type (and the test relies on that
property to run as expected or to not generate any unexpected warnings).
Other failures occur when arrays larger than what is supported for 16-bit
targets are declared, or the "short" type is expected to be smaller than "int".

The fixes fall into a few different categories:
- Explicitly defining a 32-bit int type and using that in place of "int" or
  "unsigned int".
- Skipping tests which rely on arrays sized larger than what is supported by the
  target.
- Adding or adjusting dg-{warning,error} directives
- Other testcase specific adjustments.

I've successfully regtested the patch on x86_64-pc-linux-gnu and msp430-elf in
the default, -mlarge and -mcpu=msp430 configurations.

There are no absolute changes to testresults on x86_64-pc-linux-gnu, but because
of changes to the line number of dg-{warning,message,error,etc} directives, the
results comparison shows:
UNTESTED->FAIL: 8 tests
UNTESTED->PASS: 986 tests
PASS->UNTESTED: 986 tests
FAIL->UNTESTED: 8 tests

Across the 3 configurations for msp430, the total is:
PASS->FAIL: 0 tests
FAIL->PASS: 1108 tests
UNTESTED->FAIL: 24 tests
UNTESTED->PASS: 2924 tests
FAIL->UNTESTED: 807 tests
PASS->UNTESTED: 2564 tests

Ok for trunk?

What about for gcc-10 branch? It would be nice to clean up the testresults for
MSP430, but I understand if it is undesirable to cause these line number changes
to appear on the stable branch.

Jozef
>From 7696941c75cf7d0cfbfb25dfd9c239e28314f570 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz 
Date: Tue, 12 May 2020 14:27:41 +0100
Subject: [PATCH] TESTSUITE: Fix tests for 16-bit targets

gcc/ChangeLog:

2020-05-15  Jozef Lawrynowicz  

* doc/sourcebuild.texi: Document new short_eq_int, ptr_eq_short,
ptr_eq_int, msp430_large_memory_model and size24plus DejaGNU effective
targets.
Improve grammar in descriptions for size20plus and size32plus effective
targets.

gcc/testsuite/ChangeLog:

2020-05-15  Jozef Lawrynowicz  

* c-c++-common/builtin-has-attribute-7.c: Require size24plus.
* c-c++-common/cpp/pr63831-1.c: Store result in _has_cpp_attribute in a
long.
* c-c++-common/pr81376.c: Skip scan-tree-dump for short_eq_int. Extend
test for short_eq_int.
* g++.dg/abi/scoped1.C: Skip dg-warning tests for short_eq_int.
* g++.dg/cpp0x/constexpr-70001-1.C: Require size24plus.
* g++.dg/cpp0x/constexpr-bitfield3.C: Require int32plus.
* g++.dg/cpp0x/enum13.C: Skip dg-warning for short_eq_int.
* g++.dg/cpp0x/initlist5.C: Add dg-error for short_eq_int.
* g++.dg/cpp0x/initlist7.C: Add dg-warning for !int32plus.
* g++.dg/cpp0x/nullptr04.C: Skip dg-error for ptr_eq_short.
* g++.dg/cpp0x/variadic-value1.C: Add typedef for int32_t.
* g++.dg/cpp1y/constexpr-arith-overflow.C: Fix test for
sizeof(int) == sizeof(short).
* g++.dg/cpp1y/digit-sep-neg.C: Add typedef for int32_t.
* g++.dg/cpp1y/pr57644.C: Add typedef for uint32_t.
* g++.dg/cpp1y/pr77321.C: Require size24plus.
* g++.dg/cpp1y/var-templ4.C: Add typedef for int32_t.
* g++.dg/cpp1z/direct-enum-init1.C: Skip dg-error for short_eq_int.
* g++.dg/delayedfold/fwrapv1.C: Skip for int16.
* g++.dg/expr/bitfield9.C: Add typedef for int32_t.
* g++.dg/ext/attribute-test-1.C: Add typedef for uint32_t.
* g++.dg/ext/bitfield1.C: Add typedef for int32_t.
* g++.dg/ext/flexary13.C: Add typedef for int32_t.
* g++.dg/ext/utf-cvt.C: Adjust dg-warning for int16.
* g++.dg/ext/vector28.C: Add typedef for int32_t.
* g++.dg/ext/vla15.C: Add typedef for int32_t.
* g++.dg/init/array11.C: Require size32plus.
* g++.dg/init/array15.C: Require size24plus.
* g++.dg/init/array4.C: Require size20plus.
* g++.dg/init/const7.C: Skip dg-message for ptr_eq_int.
* g++.dg/init/new38.C: Relax regex in dg-error.
* g++.dg/init/new44.C: Skip dg-error for when ptr_eq_int.
Adjust test for 16-bit size_t.
Add special case for msp430 -mlarge.
* g++.dg/init/value9.C: Add typedef for int32_t.
* g++.dg/ipa/pr77333.C: Add typedef for int32_t.
* g++.dg/lto/20080908-1_0.C: Add typedef for int32_t.
* g++.dg/opt/pr55717.C: Add typedef for uint32_t.
* g++.dg/opt/pr60597.C: Add typedef for int32_t.
* g++.dg/opt/pr81715.C: Require size20plus.
* g++.dg/opt/reload3.C: Add typedef for uint32_t.
* g++.dg/opt/te