]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR testsuite/101468 - Wstringop-overflow tests failures
authorMartin Sebor <msebor@redhat.com>
Fri, 16 Jul 2021 17:08:58 +0000 (11:08 -0600)
committerMartin Sebor <msebor@redhat.com>
Fri, 16 Jul 2021 17:11:23 +0000 (11:11 -0600)
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.

gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
gcc/testsuite/gcc.dg/Wstringop-overflow-70.c
gcc/testsuite/gcc.dg/Wstringop-overflow-71.c
gcc/testsuite/gcc.dg/strlenopt-95.c

index 9b2d2cbc5015d96e46805d49d4cda3bec5343e15..e255e6702972e51c0e9bc55756228818ee0467bb 100644 (file)
@@ -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" }
index 4bb22f2ecd3c922f3ed5f9d40fd9699db3fd2013..8527eea8e5a3a641e121dc8f5dcd3d40fd3c987f 100644 (file)
@@ -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);
 }
index d2d3ae5f853302d6cadfee6b119b332c8af4608f..6bcba2745410b3554a43ac8fe547fc6a77460d69 100644 (file)
@@ -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)
index 5d8bfa9a7041a47c2fedaa384c83895a8f8a1d44..82c4d9f2238748fb2c27786f0b6453f28064cd41 100644 (file)
@@ -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;
 }
index dccee35cb3d272ac4fa18a495fad3b617c3133b2..f56a00560b0016400f6cb07af694e1d9b69b0e69 100644 (file)
@@ -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 } } }
 }
index 505bc996a5918e7d5c1522f798794bdce34a4e3e..6e0a79d3e691fe2ad1a4cec195656134e471c2dd 100644 (file)
@@ -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" } } */