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
> <joze...@mittosystems.com> wrote:
> >
> > On Fri, May 15, 2020 at 10:48:56PM +0000, 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 <joze...@mittosystems.com>
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 <cstddef>
 
-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 <int I>
@@ -15,7 +20,18 @@ template <class T>
 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 warn_for_NULL()
 {
diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-null.C 
b/gcc/testsuite/g++.dg/warn/Wconversion-null.C
index 4cac2671116..4c68d233450 100644
--- a/gcc/testsuite/g++.dg/warn/Wconversion-null.C
+++ b/gcc/testsuite/g++.dg/warn/Wconversion-null.C
@@ -3,7 +3,12 @@
 
 #include <cstddef>
 
-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 <int I>
@@ -15,7 +20,18 @@ template <class T>
 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
 
 int main()
 {
-- 
2.26.2

Reply via email to