[testsuite] Rectify some tests

Message ID 73e46732-5647-4a11-906d-61b8be066b80@gjlay.de
State New
Headers
Series [testsuite] Rectify some tests |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm fail Patch failed to apply

Commit Message

Georg-Johann Lay Dec. 3, 2024, 11:08 a.m. UTC
  This patch fixes some unrelated tests that were failing.
In most cases, bad tests are slipping in because they
are preprocessed like:

size_t -> long unsigned int -> breaks when size_t is smaller etc.

Other reason is that they assume int is > 16 bits.

Unfortunately, in many cases it's not known how a bug reproducer
works exactly and whether replacing int -> int32_t won't spoil
the test case; hence add some dg-require-effective-target.

Ok for trunk?

Johann

--

Rectify some test cases.

	PR testsuite/52641
gcc/testsuite/
	* gcc.dg/Wuse-after-free-pr109123.c: Use size_t
	instead of long unsigned int.
	* gcc.dg/c23-tag-bitfields-1.c: Requires int32plus.
	* gcc.dg/pr114661.c: Same.
	* gcc.dg/pr117828.c: Same.
	* gcc.dg/flex-array-counted-by-2.c: Use uintptr_t
	instead of unsigned long.
	* gcc.dg/pr116481.c: Same.
	* gcc.dg/lto/tag-1_0.c: Use int32_t instead of int.
	* gcc.dg/lto/tag-1_1.c: Use int16_t instead of short.
	* gcc.dg/pr91069.c: Require double64.
	* gcc.dg/type-convert-var.c: Require double64plus.
  

Comments

Mike Stump Dec. 3, 2024, 9:52 p.m. UTC | #1
On Dec 3, 2024, at 3:08 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
> 
> This patch fixes some unrelated tests that were failing.
> In most cases, bad tests are slipping in because they
> are preprocessed like:
> 
> size_t -> long unsigned int -> breaks when size_t is smaller etc.
> 
> Other reason is that they assume int is > 16 bits.
> 
> Unfortunately, in many cases it's not known how a bug reproducer
> works exactly and whether replacing int -> int32_t won't spoil
> the test case; hence add some dg-require-effective-target.
> 
> Ok for trunk?

Ok.
  

Patch

    Rectify some test cases.
    
            PR testsuite/52641
    gcc/testsuite/
            * gcc.dg/Wuse-after-free-pr109123.c: Use size_t
            instead of long unsigned int.
            * gcc.dg/c23-tag-bitfields-1.c: Requires int32plus.
            * gcc.dg/pr114661.c: Same.
            * gcc.dg/pr117828.c: Same.
            * gcc.dg/flex-array-counted-by-2.c: Use uintptr_t
            instead of unsigned long.
            * gcc.dg/pr116481.c: Same.
            * gcc.dg/lto/tag-1_0.c: Use int32_t instead of int.
            * gcc.dg/lto/tag-1_1.c: Use int16_t instead of short.
            * gcc.dg/pr91069.c: Require double64.
            * gcc.dg/type-convert-var.c: Require double64plus.

diff --git a/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c b/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c
index ece066dd28b..8e6fc3aa014 100644
--- a/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c
+++ b/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c
@@ -1,7 +1,7 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -Wall" } */
 
-typedef long unsigned int size_t;
+typedef __SIZE_TYPE__ size_t;
 extern void *realloc (void *__ptr, size_t __size)
      __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)) __attribute__ ((__alloc_size__ (2)));
 struct vector_objective; 
diff --git a/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c b/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c
index d775d9f67a1..8ee8d47586c 100644
--- a/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c
+++ b/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c
@@ -1,5 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-std=c23" } */
+/* { dg-require-effective-target int32plus } */
 
 struct bar0 { int r : 16; };
 struct bar0 { int r : 16; };
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
index d4899a63af3..42d6436cec2 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
@@ -5,6 +5,8 @@ 
 
 #include <stdlib.h>
 
+typedef __UINTPTR_TYPE__ uintptr_t;
+
 struct annotated {
   int b;
   char c[] __attribute__ ((counted_by (b)));
@@ -86,10 +88,10 @@  void __attribute__((__noinline__)) test (char a, char b)
   if (__alignof (array_nested_annotated->c) != __alignof (char))
     abort ();
 
-  if ((unsigned long) array_annotated->c != (unsigned long) &array_annotated->c)
+  if ((uintptr_t) array_annotated->c != (uintptr_t) &array_annotated->c)
     abort ();
-  if ((unsigned long) array_nested_annotated->c
-       != (unsigned long) &array_nested_annotated->c)
+  if ((uintptr_t) array_nested_annotated->c
+       != (uintptr_t) &array_nested_annotated->c)
     abort ();
 
   array_annotated->c[2] = a;
diff --git a/gcc/testsuite/gcc.dg/lto/tag-1_0.c b/gcc/testsuite/gcc.dg/lto/tag-1_0.c
index c9b0c719f4e..87ca7fa5d08 100644
--- a/gcc/testsuite/gcc.dg/lto/tag-1_0.c
+++ b/gcc/testsuite/gcc.dg/lto/tag-1_0.c
@@ -1,5 +1,5 @@ 
 /* { dg-lto-do link } */
 /* { dg-lto-options { { -Wodr -flto } } }  */
 
-struct foo { int x; };
+struct foo { __INT32_TYPE__ x; };
 struct foo a = {};
diff --git a/gcc/testsuite/gcc.dg/lto/tag-1_1.c b/gcc/testsuite/gcc.dg/lto/tag-1_1.c
index 443f9109811..3c6db5a37ec 100644
--- a/gcc/testsuite/gcc.dg/lto/tag-1_1.c
+++ b/gcc/testsuite/gcc.dg/lto/tag-1_1.c
@@ -1,4 +1,4 @@ 
-struct foo { short x; };
+struct foo { __INT16_TYPE__ x; };
 
 extern struct foo a; /* { dg-lto-warning {type of 'a' does not match original declaration} } */
 struct foo *ptr = &a;
diff --git a/gcc/testsuite/gcc.dg/pr114661.c b/gcc/testsuite/gcc.dg/pr114661.c
index e6b5c69dba8..8ea3f8d7d47 100644
--- a/gcc/testsuite/gcc.dg/pr114661.c
+++ b/gcc/testsuite/gcc.dg/pr114661.c
@@ -1,5 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-require-effective-target int32plus } */
 
 unsigned mul(unsigned char c) {
     if (c > 3) __builtin_unreachable();
diff --git a/gcc/testsuite/gcc.dg/pr116481.c b/gcc/testsuite/gcc.dg/pr116481.c
index 3ee6d747087..14afb8e1580 100644
--- a/gcc/testsuite/gcc.dg/pr116481.c
+++ b/gcc/testsuite/gcc.dg/pr116481.c
@@ -6,8 +6,9 @@  extern void tramp ();
 int is_trampoline (void* function) /* { dg-bogus "arrays of functions are not meaningful" } */
 {
   void* tramp_address = tramp;
-  if (!(((unsigned long)function & 3) == 2))
+  if (!(((__UINTPTR_TYPE__)function & 3) == 2))
     return 0;
   return (((long *) ((char*)function - 2))[0]
 	  == ((long *) ((char*)tramp_address-2))[0]); /* { dg-warning "outside array bounds" } */
 }
+/* { dg-warning "accessing data memory with program memory address.*" "" { target avr-*-* } .-1 } */
diff --git a/gcc/testsuite/gcc.dg/pr117828.c b/gcc/testsuite/gcc.dg/pr117828.c
index d6750310d97..54e8d62265e 100644
--- a/gcc/testsuite/gcc.dg/pr117828.c
+++ b/gcc/testsuite/gcc.dg/pr117828.c
@@ -1,5 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-g" } */
+/* { dg-require-effective-target int32plus } */
 
 struct {
   struct {
diff --git a/gcc/testsuite/gcc.dg/pr91069.c b/gcc/testsuite/gcc.dg/pr91069.c
index fdb2cfd062f..e5bd7b684d3 100644
--- a/gcc/testsuite/gcc.dg/pr91069.c
+++ b/gcc/testsuite/gcc.dg/pr91069.c
@@ -1,8 +1,9 @@ 
 /* { dg-do run } */
 /* { dg-options "-std=gnu11" } */
+/* { dg-require-effective-target double64 } */
 
 typedef double v2df __attribute__((vector_size(2 * sizeof (double))));
-typedef long long v2di __attribute__((vector_size(2 * sizeof (long long))));
+typedef __INT64_TYPE__ v2di __attribute__((vector_size(2 * sizeof (__INT64_TYPE__))));
 
 void foo (v2df *res, v2df *src)
 {
diff --git a/gcc/testsuite/gcc.dg/type-convert-var.c b/gcc/testsuite/gcc.dg/type-convert-var.c
index f7b191ce2da..6f8269abe04 100644
--- a/gcc/testsuite/gcc.dg/type-convert-var.c
+++ b/gcc/testsuite/gcc.dg/type-convert-var.c
@@ -1,5 +1,7 @@ 
 /* { dg-do compile } */
 /* { dg-additional-options "-fexcess-precision=fast -O1 -fdump-tree-optimized" } */
+/* { dg-require-effective-target double64plus } */
+
 void foo (float a, float b, float *c)
 {
   double e = (double)a * (double)b;