aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-07-16 11:08:58 -0600
committerMartin Sebor <msebor@redhat.com>2021-07-16 11:11:23 -0600
commit94ba897be8b59ef5926eed4c77fd53812fb20add (patch)
tree461f568c74597a211f1e833f1930ff2b83591da7 /gcc
parentfa5f8b49e55caf5bb341f5eb6b5ab828b9286425 (diff)
downloadgcc-94ba897be8b59ef5926eed4c77fd53812fb20add.zip
gcc-94ba897be8b59ef5926eed4c77fd53812fb20add.tar.gz
gcc-94ba897be8b59ef5926eed4c77fd53812fb20add.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-41.c3
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-42.c12
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-68.c12
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-70.c5
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-71.c22
-rw-r--r--gcc/testsuite/gcc.dg/strlenopt-95.c8
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 9b2d2cb..e255e67 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 4bb22f2..8527eea 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 d2d3ae5..6bcba27 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 5d8bfa9..82c4d9f 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 dccee35..f56a005 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 505bc99..6e0a79d 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" } } */