[gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] PR testsuite/92829 - several -Wstringop-overflow test case failures on powerpc64

Martin Liska marxin@gcc.gnu.org
Mon Mar 30 10:17:29 GMT 2020


https://gcc.gnu.org/g:414231ba78973dfcb11648a0a5287b989e0148bb

commit 414231ba78973dfcb11648a0a5287b989e0148bb
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon Jan 20 14:53:33 2020 +0100

    PR testsuite/92829 - several -Wstringop-overflow test case failures on powerpc64
    
            * g++.dg/warn/Wstringop-overflow-4.C: Adjust test to avoid failures
            due to an aparrent VRP limtation.
            * gcc.dg/Wstringop-overflow-25.c: Same.

Diff:
---
 gcc/testsuite/ChangeLog                          |  7 +++++++
 gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C | 16 +++++++++++-----
 gcc/testsuite/gcc.dg/Wstringop-overflow-25.c     | 14 ++++++++++----
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 67d5f2e9e28..452c16eb8c5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2020-01-20  Martin Sebor  <msebor@redhat.com>
+
+	PR testsuite/92829
+	* g++.dg/warn/Wstringop-overflow-4.C: Adjust test to avoid failures
+	due to an aparrent VRP limtation.
+	* gcc.dg/Wstringop-overflow-25.c: Same.
+
 2020-01-20  Nathan Sidwell  <nathan@acm.org>
 
 	PR preprocessor/80005
diff --git a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C
index b6fe0289674..121239ac1db 100644
--- a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C
+++ b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C
@@ -98,13 +98,19 @@ void test_strcpy_new_char_array (size_t n)
 
 #ifdef __INT16_TYPE__
 
+// Hack around PR 92829.
+#define XUR(min, max) \
+  (++idx, (vals[idx] < min || max < vals[idx] ? min : vals[idx]))
+
 typedef __INT16_TYPE__ int16_t;
 
-void test_strcpy_new_int16_t (size_t n)
+void test_strcpy_new_int16_t (size_t n, const size_t vals[])
 {
-  size_t r_0_1 = UR (0, 1);
-  size_t r_1_2 = UR (1, 2);
-  size_t r_2_3 = UR (2, 3);
+  size_t idx = 0;
+
+  size_t r_0_1 = XUR (0, 1);
+  size_t r_1_2 = XUR (1, 2);
+  size_t r_2_3 = XUR (2, 3);
 
   T (S (0), new int16_t[r_0_1]);
   T (S (1), new int16_t[r_0_1]);
@@ -122,7 +128,7 @@ void test_strcpy_new_int16_t (size_t n)
   T (S (6), new int16_t[r_2_3]);      // { dg-warning "\\\[-Wstringop-overflow" }
   T (S (9), new int16_t[r_2_3]);      // { dg-warning "\\\[-Wstringop-overflow" }
 
-  size_t r_2_smax = UR (2, SIZE_MAX);
+  size_t r_2_smax = XUR (2, SIZE_MAX);
   T (S (0), new int16_t[r_2_smax]);
   T (S (1), new int16_t[r_2_smax]);
   T (S (2), new int16_t[r_2_smax]);
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c
index 1b38dfe9ae4..01807207acc 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c
@@ -290,11 +290,17 @@ NOIPA void test_strcpy_alloc2_4 (void)
     sink (vla);					\
   } while (0)
 
-NOIPA void test_strcpy_vla (void)
+// Hack around PR 92829.
+#define XUR(min, max) \
+  (++idx, (vals[idx] < min || max < vals[idx] ? min : vals[idx]))
+
+NOIPA void test_strcpy_vla (const size_t vals[])
 {
-  size_t r_0_1 = UR (0, 1);
-  size_t r_1_2 = UR (1, 2);
-  size_t r_2_3 = UR (2, 3);
+  size_t idx = 0;
+
+  size_t r_0_1 = XUR (0, 1);
+  size_t r_1_2 = XUR (1, 2);
+  size_t r_2_3 = XUR (2, 3);
 
   T (char, S (0), r_0_1);
   T (char, S (1), r_0_1);       // { dg-warning "\\\[-Wstringop-overflow" }


More information about the Gcc-cvs mailing list