testsuite: Fix up c2x-enum-1.c for 32-bit arches [PR107311]

Message ID Y1AkY7V2xil5Wpub@tucnak
State Unresolved
Headers
Series testsuite: Fix up c2x-enum-1.c for 32-bit arches [PR107311] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek Oct. 19, 2022, 4:22 p.m. UTC
  Hi!

On Wed, Oct 19, 2022 at 02:57:59PM +0000, Joseph Myers wrote:
> I think the type checked for e5a should be conditional on __LONG_MAX__ > 
> __INT_MAX__; everything else there should be OK regardless.

So like this?
Tested on x86_64-linux with -m32 and -m64, ok for trunk?

2022-10-19  Jakub Jelinek  <jakub@redhat.com>

	PR c/107311
	* gcc.dg/c2x-enum-1.c (enum e5): Expect e5a type inside of
	enum to be int rather than long if long isn't wider than int.



	Jakub
  

Comments

Joseph Myers Oct. 19, 2022, 4:28 p.m. UTC | #1
On Wed, 19 Oct 2022, Jakub Jelinek wrote:

> Hi!
> 
> On Wed, Oct 19, 2022 at 02:57:59PM +0000, Joseph Myers wrote:
> > I think the type checked for e5a should be conditional on __LONG_MAX__ > 
> > __INT_MAX__; everything else there should be OK regardless.
> 
> So like this?
> Tested on x86_64-linux with -m32 and -m64, ok for trunk?
> 
> 2022-10-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c/107311
> 	* gcc.dg/c2x-enum-1.c (enum e5): Expect e5a type inside of
> 	enum to be int rather than long if long isn't wider than int.

OK.
  

Patch

--- gcc/testsuite/gcc.dg/c2x-enum-1.c.jj	2022-10-19 01:15:21.025186231 +0200
+++ gcc/testsuite/gcc.dg/c2x-enum-1.c	2022-10-19 18:19:45.215215713 +0200
@@ -82,7 +82,12 @@  enum e5 { e5a = __LONG_MAX__,
 	  e5b, e5c, e5d = ((typeof (e5b)) -1) < 0,
 	  e5e = (unsigned long) -1,
 	  e5f, e5g = ((typeof (e5e)) -1) > 0,
-	  TYPE_CHECK (e5a, long), TYPE_CHECK (e5e, unsigned long) };
+#if __LONG_MAX__ > __INT_MAX__
+	  TYPE_CHECK (e5a, long),
+#else
+	  TYPE_CHECK (e5a, int),
+#endif
+	  TYPE_CHECK (e5e, unsigned long) };
 extern enum e5 e5v;
 extern typeof (e5a) e5v;
 extern typeof (e5b) e5v;