+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
#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]);
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]);
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" }