diff mbox series

gomp: testsuite: improve compatibility of bad-array-section-3.c [PR113428]

Message ID 20240306171944.1894424-1-rearnsha@arm.com
State New
Headers show
Series gomp: testsuite: improve compatibility of bad-array-section-3.c [PR113428] | expand

Commit Message

Richard Earnshaw March 6, 2024, 5:19 p.m. UTC
This test generates different warnings on ilp32 targets because the size
of an integer matches the size of a pointer.  Avoid this by using
signed char.

gcc/testsuite:

	PR testsuite/113428
	* gcc.dg/gomp/bad-array-section-c-3.c: Use signed char instead
	of int.
---

I think this fixes the issues seen on ilp32 machines, without substantially
changing what the test does, but a second set of eyes wouldn't hurt.

 gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Richard Sandiford March 8, 2024, 6:18 p.m. UTC | #1
Richard Earnshaw <rearnsha@arm.com> writes:
> This test generates different warnings on ilp32 targets because the size
> of an integer matches the size of a pointer.  Avoid this by using
> signed char.
>
> gcc/testsuite:
>
> 	PR testsuite/113428
> 	* gcc.dg/gomp/bad-array-section-c-3.c: Use signed char instead
> 	of int.
> ---
>
> I think this fixes the issues seen on ilp32 machines, without substantially
> changing what the test does, but a second set of eyes wouldn't hurt.
>
>  gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

It looks good to me FWIW, but I'd feel more comfortable with an OK
from Jakub.

OK midday Monday UK time if no-one objects by then.

Richard

>
> diff --git a/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c b/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c
> index 8be15ced8c0..431af71c422 100644
> --- a/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c
> +++ b/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c
> @@ -1,15 +1,15 @@
>  /* { dg-do compile } */
>  
>  struct S {
> -  int *ptr;
> +  signed char *ptr;
>  };
>  
>  int main()
>  {
> -  int arr[20];
> +  signed char arr[20];
>  
>    /* Reject array section in compound initialiser.  */
> -#pragma omp target map( (struct S) { .ptr = (int *) arr[5:5] } )
> +#pragma omp target map( (struct S) { .ptr = (signed char *) arr[5:5] } )
>  /* { dg-error {expected '\]' before ':' token} "" { target *-*-* } .-1 } */
>  /* { dg-warning {cast to pointer from integer of different size} "" { target *-*-* } .-2 } */
>  /* { dg-message {sorry, unimplemented: unsupported map expression} "" { target *-*-* } .-3 } */
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c b/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c
index 8be15ced8c0..431af71c422 100644
--- a/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c
+++ b/gcc/testsuite/gcc.dg/gomp/bad-array-section-c-3.c
@@ -1,15 +1,15 @@ 
 /* { dg-do compile } */
 
 struct S {
-  int *ptr;
+  signed char *ptr;
 };
 
 int main()
 {
-  int arr[20];
+  signed char arr[20];
 
   /* Reject array section in compound initialiser.  */
-#pragma omp target map( (struct S) { .ptr = (int *) arr[5:5] } )
+#pragma omp target map( (struct S) { .ptr = (signed char *) arr[5:5] } )
 /* { dg-error {expected '\]' before ':' token} "" { target *-*-* } .-1 } */
 /* { dg-warning {cast to pointer from integer of different size} "" { target *-*-* } .-2 } */
 /* { dg-message {sorry, unimplemented: unsupported map expression} "" { target *-*-* } .-3 } */