[testuite,committed] Fix some more tests that fail for non 32-bit int targets

Message ID 87zip6udul.fsf@atmel.com
State New
Headers show

Commit Message

Senthil Kumar Selvaraj July 25, 2016, noon
Hi,

  The below patch fixes tests that fail for the avr target, because they
  assume ints are atleast 32 bits wide and pointers and longs have the
  same size.

  I've required int32plus support for one test, and for the other two,
  I've introduced a cast to intptr_t to avoid the pointer <-> int size
  difference warning.

  Reg tested on avr and x86_64 with no regressions. Committed as
  obvious.

Regards
Senthil

gcc/testsuite/ChangeLog

2016-07-25  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	* gcc.dg/torture/pr69352.c (foo): Cast to intptr_t instead of long.
	* gcc.dg/torture/pr69771.c: Require int32plus.
	* gcc.dg/torture/pr71866.c (inb): Add cast to intptr_t.

Comments

Mike Stump July 25, 2016, 5:10 p.m. | #1
On Jul 25, 2016, at 5:00 AM, Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> wrote:
> 
>  The below patch fixes tests that fail for the avr target, because they
>  assume ints are atleast 32 bits wide and pointers and longs have the
>  same size.
> 
>  I've required int32plus support for one test, and for the other two,
>  I've introduced a cast to intptr_t to avoid the pointer <-> int size
>  difference warning.
> 
>  Reg tested on avr and x86_64 with no regressions. Committed as
>  obvious.

Can you use __INTPTR_TYPE__ instead?  This way, you don't need to add any include, and the test case will work in cross environments without any libc, which is at times handy.  Thanks.

See grep INTPTR gcc/gcc/testsuite/gcc.dg/*.c for how people use it, and for the unsigned version.

> 2016-07-25  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
> 
> 	* gcc.dg/torture/pr69352.c (foo): Cast to intptr_t instead of long.
> 	* gcc.dg/torture/pr69771.c: Require int32plus.
> 	* gcc.dg/torture/pr71866.c (inb): Add cast to intptr_t.

Patch

Index: gcc.dg/torture/pr69352.c
===================================================================
--- gcc.dg/torture/pr69352.c	(revision 238707)
+++ gcc.dg/torture/pr69352.c	(working copy)
@@ -1,5 +1,7 @@ 
 /* { dg-do compile } */
 
+#include <stdint.h>
+
 int a[10][14], b, c, d, e, f, g, h, i;
 void bar (void);
 int
@@ -13,7 +15,7 @@ 
   else
     m = 13;
   if (a[x][m])
-    l = (long) foo;
+    l = (intptr_t) foo;
   a[x][i] = l;
   while (c)
     {
Index: gcc.dg/torture/pr69771.c
===================================================================
--- gcc.dg/torture/pr69771.c	(revision 238707)
+++ gcc.dg/torture/pr69771.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* PR rtl-optimization/69771 */
 /* { dg-do compile } */
+/* { dg-require-effective-target int32plus } */
 
 unsigned char a = 5, c;
 unsigned short b = 0;
Index: gcc.dg/torture/pr71866.c
===================================================================
--- gcc.dg/torture/pr71866.c	(revision 238707)
+++ gcc.dg/torture/pr71866.c	(working copy)
@@ -1,6 +1,7 @@ 
 /* { dg-do compile } */
 /* { dg-additional-options "-ftree-pre -fcode-hoisting" } */
 
+#include <stdint.h>
 typedef unsigned char u8;
 extern unsigned long pci_io_base;
 u8 in_8 (const volatile void *);
@@ -25,7 +26,7 @@ 
 static inline
 u8 inb (unsigned long port)
 {
-  return readb((volatile void *)pci_io_base + port);
+  return readb((volatile void *)(intptr_t)pci_io_base + port);
 }
 static inline
 void outb (u8 val, unsigned long port)