diff mbox series

[testsuite,applied] PR52641: Fix more sloppy tests.

Message ID ef290954-7ad7-46bd-9910-03bc26ab84de@gjlay.de
State New
Headers show
Series [testsuite,applied] PR52641: Fix more sloppy tests. | expand

Commit Message

Georg-Johann Lay July 6, 2024, 1:14 p.m. UTC
Such tests exists because pre-processed sources are used
as test cases, like they are provided in PRs.

This means they have, say, "unsigned long" instead of size_t,
but "unsigned long" is not a correct size_t on some targets.

Some of the tests can be transformed back so that they use __SIZE_TYPE__
but for other tests it's not possible to reverse engineer the
spirit of the test case.

Similar problems are when int32_t is replaced by "int", or
intptr_t is replaced by "long", etc.

For test cases that use integer constants larger that 16 bits,
it is unclear whether the test case still reproduces the
same artifact when the constant is replaced by a smaller one;
or if it still works when int is replaced by int32_t etc.

Johann

--

testsuite/52641 - Fix more sloppy tests.

	PR testsuite/52641
gcc/testsuite/
	* gcc.dg/analyzer/torture/boxed-ptr-1.c: Requires size24plus.
	* gcc.dg/analyzer/torture/pr102692.c: Use intptr_t instead of long.
	* gcc.dg/ipa/pr102714.c: Use uintptr_t instead of unsigned long.
	* gcc.dg/torture/pr115387-1.c: Same.
	* gcc.dg/torture/pr113895-1.c : Same.
	* gcc.dg/ipa/pr108007.c: Require int32plus.
	* gcc.dg/ipa/pr109318.c: Same.
	* gcc.dg/ipa/pr96040.c: Use size_t instead of unsigned long.
	* gcc.dg/torture/pr113126.c: Use vectors of same dimension.
	* gcc.dg/tree-ssa/builtin-sprintf-9.c: Requires double64.

	* gcc.dg/spellcheck-inttypes.c [avr]: Avoid include of inttypes.h.
	* gcc.dg/analyzer/torture/pr104159.c [avr]: Skip.
	* gcc.dg/torture/pr84682-2.c [avr]: Skip.
	* gcc.dg/wtr-conversion-1.c [avr]: Remove avr selector since
	long double is a 64-bit type by now.
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/boxed-ptr-1.c b/gcc/testsuite/gcc.dg/analyzer/torture/boxed-ptr-1.c
index 5bc7151a798..e25d0c31ea5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/torture/boxed-ptr-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/boxed-ptr-1.c
@@ -1,4 +1,5 @@ 
 /* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+/* { dg-require-effective-target size24plus } */
 
 #include <stdlib.h>
 #include "../analyzer-decls.h"
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr102692.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr102692.c
index a6c6bc47896..a1b3bfed047 100644
--- a/gcc/testsuite/gcc.dg/analyzer/torture/pr102692.c
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr102692.c
@@ -15,7 +15,7 @@  make_lisp_ptr (void *ptr, int type)
 static _Bool
 TAGGEDP (struct lisp *a, unsigned tag)
 {
-  return ! (((unsigned) (long) a - tag) & 7);
+  return ! (((unsigned) (__INTPTR_TYPE__) a - tag) & 7);
 }
 
 static _Bool
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr104159.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr104159.c
index ad85d084b39..0c490bd39f2 100644
--- a/gcc/testsuite/gcc.dg/analyzer/torture/pr104159.c
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr104159.c
@@ -1,4 +1,5 @@ 
 /* { dg-additional-options "-Wno-analyzer-use-of-uninitialized-value -Wno-psabi" } */
+/* { dg-skip-if "incompatible types" { "avr-*-*" } } */
 
 typedef int __attribute__((__vector_size__(4))) T;
 typedef unsigned __attribute__((__vector_size__(4))) U;
diff --git a/gcc/testsuite/gcc.dg/ipa/pr102714.c b/gcc/testsuite/gcc.dg/ipa/pr102714.c
index 65dd86f5c15..8ab77a61d75 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr102714.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr102714.c
@@ -54,16 +54,16 @@  static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attr
 
 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) struct xa_node *entry_to_node(void *ptr)
 {
- return (void *)((unsigned long)ptr & ~2UL);
+ return (void *)((__UINTPTR_TYPE__)ptr & ~(__UINTPTR_TYPE__)2);
 }
 
 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) bool radix_tree_is_internal_node(void *ptr)
 {
- return ((unsigned long)ptr & 3UL) ==
+ return ((__UINTPTR_TYPE__)ptr & 3UL) ==
     2UL;
 }
 
-static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) void *xa_mk_internal(unsigned long v)
+static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) void *xa_mk_internal(__UINTPTR_TYPE__ v)
 {
  return (void *)((v << 2) | 2);
 }
diff --git a/gcc/testsuite/gcc.dg/ipa/pr108007.c b/gcc/testsuite/gcc.dg/ipa/pr108007.c
index 77fc95975cf..5bd1c350963 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr108007.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr108007.c
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-Os -fno-dce -fno-tree-dce -g" } */
+/* { dg-require-effective-target int32plus } */
 
 /* This tests that when IPA-SRA removes a LHS of a call statement which, in the
    original source, is fed into a useless operation which however can trap when
diff --git a/gcc/testsuite/gcc.dg/ipa/pr109318.c b/gcc/testsuite/gcc.dg/ipa/pr109318.c
index c5d9e3d12c7..68e9f62eb37 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr109318.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr109318.c
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-O2 -fno-early-inlining" } */
+/* { dg-require-effective-target int32plus } */
 
 #pragma pack(1)
 struct S {
diff --git a/gcc/testsuite/gcc.dg/ipa/pr96040.c b/gcc/testsuite/gcc.dg/ipa/pr96040.c
index af7e9c4ed94..9c9b76269a6 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr96040.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr96040.c
@@ -3,8 +3,8 @@ 
 
 
 int puts(const char *);
-int snprintf(char *, unsigned long, const char *, ...);
-unsigned long strspn(const char *, const char *);
+int snprintf(char *, __SIZE_TYPE__, const char *, ...);
+__SIZE_TYPE__ strspn(const char *, const char *);
 
 struct TValue {
   union {
diff --git a/gcc/testsuite/gcc.dg/spellcheck-inttypes.c b/gcc/testsuite/gcc.dg/spellcheck-inttypes.c
index 24e075433fc..084a5cd4314 100644
--- a/gcc/testsuite/gcc.dg/spellcheck-inttypes.c
+++ b/gcc/testsuite/gcc.dg/spellcheck-inttypes.c
@@ -3,6 +3,13 @@ 
 #ifdef _AIX
 #define _STD_TYPES_T
 #endif
+
+/* Prevent AVR-LibC from implicitly including inttypes.h.  */
+#ifdef __AVR__
+#define __INTTYPES_H_
+#include <stdint.h>
+#endif
+
 #include <stdio.h>
 #include <stdint.h>
 /* Missing <inttypes.h>.  */
diff --git a/gcc/testsuite/gcc.dg/torture/pr113126.c b/gcc/testsuite/gcc.dg/torture/pr113126.c
index ffe29799d13..75d05e47972 100644
--- a/gcc/testsuite/gcc.dg/torture/pr113126.c
+++ b/gcc/testsuite/gcc.dg/torture/pr113126.c
@@ -1,8 +1,8 @@ 
 /* { dg-do compile } */
 /* { dg-additional-options "-Wno-psabi" } */
 
-typedef float __attribute__((__vector_size__ (8))) F;
-typedef double __attribute__((__vector_size__ (16))) G;
+typedef float __attribute__((__vector_size__ (2 * sizeof(float)))) F;
+typedef double __attribute__((__vector_size__ (2 * sizeof(double)))) G;
 
 F f;
 G g;
diff --git a/gcc/testsuite/gcc.dg/torture/pr113895-1.c b/gcc/testsuite/gcc.dg/torture/pr113895-1.c
index e96cb2f33e1..7ad682338d7 100644
--- a/gcc/testsuite/gcc.dg/torture/pr113895-1.c
+++ b/gcc/testsuite/gcc.dg/torture/pr113895-1.c
@@ -1,4 +1,5 @@ 
 /* { dg-do compile } */
+/* { dg-require-effective-target int32plus } */
 
 int main_i;
 void transparent_crc(int);
diff --git a/gcc/testsuite/gcc.dg/torture/pr115387-1.c b/gcc/testsuite/gcc.dg/torture/pr115387-1.c
index d94e935fade..7ff3ced07bf 100644
--- a/gcc/testsuite/gcc.dg/torture/pr115387-1.c
+++ b/gcc/testsuite/gcc.dg/torture/pr115387-1.c
@@ -3,7 +3,7 @@ 
 
 #define PRINTF_CHK 0x34
 
-typedef unsigned long uintptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
 
 struct __printf_buffer {
   char *write_ptr;
diff --git a/gcc/testsuite/gcc.dg/torture/pr84682-2.c b/gcc/testsuite/gcc.dg/torture/pr84682-2.c
index 5abda5fd136..f8d15c5e6a3 100644
--- a/gcc/testsuite/gcc.dg/torture/pr84682-2.c
+++ b/gcc/testsuite/gcc.dg/torture/pr84682-2.c
@@ -1,4 +1,5 @@ 
 /* { dg-do compile } */
+/* { dg-skip-if "impossible register constraint" { "avr-*-*" } } */
 
 int a;
 void b() {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-9.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-9.c
index b4a05bbd38a..3be18c7b5dc 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-9.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-9.c
@@ -1,5 +1,6 @@ 
 /* PR tree-optimization/86274 - SEGFAULT when logging std::to_string(NAN)
    { dg-do compile }
+   { dg-require-effective-target double64 }
    { dg-skip-if "not IEEE float layout" { "pdp11-*-*" } }
    { dg-options "-O2 -Wall -fdump-tree-optimized" }  */
 
diff --git a/gcc/testsuite/gcc.dg/wtr-conversion-1.c b/gcc/testsuite/gcc.dg/wtr-conversion-1.c
index 9d2cd999939..38e8d7d2085 100644
--- a/gcc/testsuite/gcc.dg/wtr-conversion-1.c
+++ b/gcc/testsuite/gcc.dg/wtr-conversion-1.c
@@ -28,8 +28,8 @@  testfunc1 ()
   foo_f (cd); /* { dg-warning "as floating rather than complex" "prototype conversion warning" } */
 
   foo_ld (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
-  foo_ld (f); /* { dg-warning "as 'float' rather than 'double'" "small double" { target { "avr-*-*" } } } */
-  foo_ld (ld);/* { dg-warning "as 'float' rather than 'double'" "small long double" { target { "avr-*-*" } } } */
+  foo_ld (f);
+  foo_ld (ld);
   foo_ld (cd);/* { dg-warning "as floating rather than complex" "prototype conversion warning" } */
 
   foo_cd (i); /* { dg-warning "as complex rather than integer" "prototype conversion warning" } */