public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2372] PR testsuite/101468 - Wstringop-overflow tests failures
@ 2021-07-16 17:11 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-07-16 17:11 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:94ba897be8b59ef5926eed4c77fd53812fb20add

commit r12-2372-g94ba897be8b59ef5926eed4c77fd53812fb20add
Author: Martin Sebor <msebor@redhat.com>
Date:   Fri Jul 16 11:08:58 2021 -0600

    PR testsuite/101468  - Wstringop-overflow tests failures
    
    gcc/testsuite/ChangeLog:
    
            PR testsuite/101468
            * gcc.dg/Wstringop-overflow-41.c: Adjust to avoid target-specific
            failures.
            * gcc.dg/Wstringop-overflow-42.c: Same.
            * gcc.dg/Wstringop-overflow-68.c: Same.
            * gcc.dg/Wstringop-overflow-70.c: Same.
            * gcc.dg/Wstringop-overflow-71.c: Same.
            * gcc.dg/strlenopt-95.c: Fix typos.

Diff:
---
 gcc/testsuite/gcc.dg/Wstringop-overflow-41.c |  3 ++-
 gcc/testsuite/gcc.dg/Wstringop-overflow-42.c | 12 ++++++------
 gcc/testsuite/gcc.dg/Wstringop-overflow-68.c | 12 ++++++------
 gcc/testsuite/gcc.dg/Wstringop-overflow-70.c |  5 ++++-
 gcc/testsuite/gcc.dg/Wstringop-overflow-71.c | 22 +++++++++++++++-------
 gcc/testsuite/gcc.dg/strlenopt-95.c          |  8 ++++----
 6 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
index 9b2d2cbc501..e255e670297 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
@@ -29,7 +29,8 @@ void char_array_cst_off_cst_size (void)
   sink (p);
 
   ++idx;
-  memset (p + idx, 0, 3);               // { dg-warning "writing 3 bytes into a region of size 1" "pr?????" { xfail ilp32 } }
+  memset (p + idx, 0, 3);               // { dg-warning "writing 3 bytes into a region of size 1" }
+  sink (p);
 
   ++idx;
   memset (p + idx, 0, 3);               // { dg-warning "writing 3 bytes into a region of size 0" }
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
index 4bb22f2ecd3..8527eea8e5a 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
@@ -23,21 +23,21 @@ void cpy_ui_1_max (unsigned i, const char *s)
 {
   if (i < 1) i = 1;
   d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" }
-  d = strcpy (a + i + 1, s);  // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail ilp32 } }
+  d = strcpy (a + i + 1, s);  // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail { ! lp64 } } }
 }
 
 void cpy_sl_1_max (long i, const char *s)
 {
   if (i < 1) i = 1;
-  d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" }
-  d = strcpy (a + i + 1, s);  // { dg-warning "writing 1 or more bytes into a region of size 0" }
+  d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
+  d = strcpy (a + i + 1, s);  // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
 }
 
 void cpy_ul_1_max (unsigned long i, const char *s)
 {
   if (i < 1) i = 1;
 
-  d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" }
+  d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
 
   /* Because of integer wraparound the offset's range is [1, 0] so
      the overflow isn't diagnosed (yet).  */
@@ -56,7 +56,7 @@ void cpy_si_min_m1 (int i, const char *s)
 void cpy_sl_min_m1 (long i, const char *s)
 {
   if (i > -1) i = -1;
-  d = strcpy (a + i - 1, s);  // { dg-warning "writing 1 or more bytes into a region of size 0" }
-  d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" }
+  d = strcpy (a + i - 1, s);  // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
+  d = strcpy (a + i, s);      // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
   d = strcpy (a + i + 2, s);
 }
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
index d2d3ae5f853..6bcba274541 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
@@ -57,12 +57,12 @@ void warn_comp_lit_zero (void)
 
 void warn_comp_lit (void)
 {
-  *(AC2*)a1 = Ac2;      // { dg-warning "writing 2 bytes into a region of size 1" "pr??????" { xfail *-*-* } }
-  *(AC4*)a2 = Ac4;      // { dg-warning "writing 4 bytes into a region of size 2" "pr??????" { xfail *-*-* } }
-  *(AC4*)a3 = Ac4;      // { dg-warning "writing 4 bytes into a region of size 3" "pr??????" { xfail *-*-* } }
-  *(AC8*)a4 = Ac8;      // { dg-warning "writing 8 bytes into a region of size 4" "pr??????" { xfail *-*-* } }
-  *(AC8*)a7 = Ac8;      // { dg-warning "writing 8 bytes into a region of size 7" "pr??????" { xfail *-*-* } }
-  *(AC16*)a15 = Ac16;   // { dg-warning "writing 16 bytes into a region of size 15" "pr??????" { xfail *-*-* } }
+  *(AC2*)a1 = Ac2;      // { dg-warning "writing 2 bytes into a region of size 1" "pr101475" { xfail *-*-* } }
+  *(AC4*)a2 = Ac4;      // { dg-warning "writing 4 bytes into a region of size 2" "pr101475" { xfail *-*-* } }
+  *(AC4*)a3 = Ac4;      // { dg-warning "writing 4 bytes into a region of size 3" "pr101475" { xfail *-*-* } }
+  *(AC8*)a4 = Ac8;      // { dg-warning "writing 8 bytes into a region of size 4" "pr101475" { xfail *-*-* } }
+  *(AC8*)a7 = Ac8;      // { dg-warning "writing 8 bytes into a region of size 7" "pr101475" { xfail *-*-* } }
+  *(AC16*)a15 = Ac16;   // { dg-warning "writing 16 bytes into a region of size 15" "pr101475" { xfail *-*-* } }
 }
 
 void warn_aggr_decl (void)
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c
index 5d8bfa9a704..82c4d9f2238 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c
@@ -16,6 +16,9 @@ void* warn_loop (void)
 {
   char *p = __builtin_malloc (15);
   for (int i = 0; i != 16; ++i)
-    p[i] = i;       // { dg-warning "writing 16 bytes into a region of size 15" }
+    /* The size of the write below depends on the target.  When vectorized
+       the vector size may be 4 or 16, otherwise it may be a series of byte
+       assignments.  */
+    p[i] = i;       // { dg-warning "writing (1|2|4|16) bytes? into a region of size (0|1|3|15)" }
   return p;
 }
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c
index dccee35cb3d..f56a00560b0 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c
@@ -12,7 +12,15 @@ extern int abs (int);
 extern void* alloca (size_t);
 
 extern double nan (const char *);
-_Decimal32 nand32 (const char *);
+
+#ifdef __DEC32_MAX__
+  _Decimal32 nand32 (const char *);
+#else
+/* _Decimal32 is supported only conditionally and not available on all
+   targets.  */
+#  define _Decimal32  double
+#  define nand32(s)   nan (s)
+#endif
 
 extern size_t strlen (const char *);
 extern char* strcpy (char *, const char *);
@@ -56,23 +64,23 @@ void warn_complex (double x, double i)
 }
 
 
-void nowarn_nan (const char *s)
+__attribute__ ((noipa)) void nowarn_nan (const char *s)
 {
   *(double *)ax = nan (s);
 }
 
-void warn_nan (const char *s)
+__attribute__ ((noipa)) void warn_nan (const char *s)
 {
   *(double *)a1 = nan (s);      // { dg-warning "\\\[-Wstringop-overflow" }
 }
 
 
-void nowarn_nand32 (const char *s)
+__attribute__ ((noipa)) void nowarn_nand32 (const char *s)
 {
   *(_Decimal32 *)ax = nand32 (s);
 }
 
-void warn_nand32 (const char *s)
+__attribute__ ((noipa)) void warn_nand32 (const char *s)
 {
   *(_Decimal32 *)a1 = nand32 (s); // { dg-warning "\\\[-Wstringop-overflow" }
 }
@@ -88,7 +96,7 @@ void nowarn_strlen (const char *s1, const char *s2, const char *s3)
 void warn_strlen (const char *s1, const char *s2)
 {
   *(int16_t *)a1 = strlen (s1); // { dg-warning "\\\[-Wstringop-overflow" }
-  *(size_t *)a2 = strlen (s2);  // { dg-warning "\\\[-Wstringop-overflow" }
+  *(size_t *)a2 = strlen (s2);  // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } }
 }
 
 
@@ -101,5 +109,5 @@ void nowarn_strcpy (char *s1, char *s2, const char *s3)
 void warn_strcpy (char *s1, char *s2, const char *s3)
 {
   *(char **)a1 = strcpy (s1, s2);   // { dg-warning "\\\[-Wstringop-overflow" }
-  *(char **)a2 = strcpy (s2, s3);   // { dg-warning "\\\[-Wstringop-overflow" }
+  *(char **)a2 = strcpy (s2, s3);   // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } }
 }
diff --git a/gcc/testsuite/gcc.dg/strlenopt-95.c b/gcc/testsuite/gcc.dg/strlenopt-95.c
index 505bc996a59..6e0a79d3e69 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-95.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-95.c
@@ -1,6 +1,6 @@
 /* Verify strlen results of vector assignments.
    { dg-do compile }
-   { dg-options "-O2 -Wall" } */
+   { dg-options "-O2 -Wall -fdump-tree-optimized" } */
 
 #include "strlenopt.h"
 
@@ -52,7 +52,7 @@ void test_fold (int i)
   *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6 };
   A (strlen (a) == 3);
 
-  *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7 };
+  *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7, 8 };
   A (strlen (a) == 3);
   A (strlen (a + 1) == 2);
   A (strlen (a + 2) == 1);
@@ -61,5 +61,5 @@ void test_fold (int i)
   A (a[4] == 5 && a[5] == 6 && a[6] == 7 && a[7] == 8);
 }
 
-/* { dg-final { scan-tree-dump-not "abort \\(" "strlen1" } }
-   { dg-final { scan-tree-dump-not "strlen \\(" "strlen1" } } */
+/* { dg-final { scan-tree-dump-not "abort \\(" "optimized" } }
+   { dg-final { scan-tree-dump-not "strlen \\(" "optimized" } } */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-16 17:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 17:11 [gcc r12-2372] PR testsuite/101468 - Wstringop-overflow tests failures Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).