aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C37
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-arith-overflow.C212
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-ice10.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/auto-fn27.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/constexpr-arith-overflow.C229
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin-arith-overflow-1.C11
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr35751.C4
-rw-r--r--gcc/testsuite/g++.dg/inherit/crash5.C14
-rw-r--r--gcc/testsuite/g++.dg/inherit/virtual1.C6
-rw-r--r--gcc/testsuite/g++.dg/init/array23.C2
-rw-r--r--gcc/testsuite/g++.dg/init/array42.C1
-rw-r--r--gcc/testsuite/g++.dg/init/array43.C2
-rw-r--r--gcc/testsuite/g++.dg/init/array44.C1
-rw-r--r--gcc/testsuite/g++.dg/init/array45.C1
-rw-r--r--gcc/testsuite/g++.dg/init/brace2.C2
-rw-r--r--gcc/testsuite/g++.dg/init/brace6.C4
-rw-r--r--gcc/testsuite/g++.dg/predict-loop-exit-1.C4
-rw-r--r--gcc/testsuite/g++.dg/predict-loop-exit-2.C4
-rw-r--r--gcc/testsuite/g++.dg/predict-loop-exit-3.C4
-rw-r--r--gcc/testsuite/g++.dg/tm/jump1.C4
21 files changed, 519 insertions, 29 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C b/gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C
new file mode 100644
index 00000000000..39592b26a58
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C
@@ -0,0 +1,37 @@
+// PR c++/71442
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-variable" }
+
+struct C
+{
+ template<typename... Ts>
+ int operator()(Ts &&...)
+ {
+ return sizeof...(Ts);
+ }
+};
+
+int
+foo ()
+{
+ C {} (1, 1L, 1LL, 1.0);
+}
+
+template<int N>
+void
+bar ()
+{
+ char a; // { dg-warning "unused variable" }
+ short b; // { dg-warning "unused variable" }
+ int c; // { dg-warning "unused variable" }
+ long d; // { dg-warning "unused variable" }
+ long long e; // { dg-warning "unused variable" }
+ float f; // { dg-warning "unused variable" }
+ double g; // { dg-warning "unused variable" }
+}
+
+void
+baz ()
+{
+ bar <0> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-arith-overflow.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-arith-overflow.C
new file mode 100644
index 00000000000..a63c0a1ef54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-arith-overflow.C
@@ -0,0 +1,212 @@
+// PR c++/70507 - integer overflow builtins not constant expressions
+// { dg-do compile { target c++11 } }
+
+#define SCHAR_MAX __SCHAR_MAX__
+#define SHRT_MAX __SHRT_MAX__
+#define INT_MAX __INT_MAX__
+#define LONG_MAX __LONG_MAX__
+#define LLONG_MAX __LONG_LONG_MAX__
+
+#define SCHAR_MIN (-__SCHAR_MAX__ - 1)
+#define SHRT_MIN (-__SHRT_MAX__ - 1)
+#define INT_MIN (-__INT_MAX__ - 1)
+#define LONG_MIN (-__LONG_MAX__ - 1)
+#define LLONG_MIN (-__LONG_LONG_MAX__ - 1)
+
+#define UCHAR_MAX (SCHAR_MAX * 2U + 1)
+#define USHRT_MAX (SHRT_MAX * 2U + 1)
+#define UINT_MAX (INT_MAX * 2U + 1)
+#define ULONG_MAX (LONG_MAX * 2LU + 1)
+#define ULLONG_MAX (LLONG_MAX * 2LLU + 1)
+
+#define USCHAR_MIN (-__USCHAR_MAX__ - 1)
+#define USHRT_MIN (-__USHRT_MAX__ - 1)
+#define UINT_MIN (-__UINT_MAX__ - 1)
+#define ULONG_MIN (-__ULONG_MAX__ - 1)
+#define ULLONG_MIN (-__ULONG_LONG_MAX__ - 1)
+
+#define Assert(expr) static_assert ((expr), #expr)
+
+template <class T>
+constexpr T add (T x, T y, T z = T ())
+{
+ return __builtin_add_overflow (x, y, &z) ? 0 : z;
+}
+
+template <class T>
+constexpr T sub (T x, T y, T z = T ())
+{
+ return __builtin_sub_overflow (x, y, &z) ? 0 : z;
+}
+
+template <class T>
+constexpr T mul (T x, T y, T z = T ())
+{
+ return __builtin_mul_overflow (x, y, &z) ? 0 : z;
+}
+
+#define TEST_ADD(T, x, y, z) Assert (z == add<T>(x, y))
+#define TEST_SUB(T, x, y, z) Assert (z == sub<T>(x, y))
+#define TEST_MUL(T, x, y, z) Assert (z == mul<T>(x, y))
+
+
+TEST_ADD (signed char, 0, 0, 0);
+TEST_ADD (signed char, 0, SCHAR_MAX, SCHAR_MAX);
+TEST_ADD (signed char, 1, SCHAR_MAX, 0); // overflow
+TEST_ADD (signed char, SCHAR_MAX, SCHAR_MAX, 0); // overflow
+TEST_ADD (signed char, 0, SCHAR_MIN, SCHAR_MIN);
+TEST_ADD (signed char, -1, SCHAR_MIN, 0); // overflow
+
+TEST_ADD (short, 0, 0, 0);
+TEST_ADD (short, 0, SHRT_MAX, SHRT_MAX);
+TEST_ADD (short, 1, SHRT_MAX, 0); // overflow
+TEST_ADD (short, SHRT_MAX, SHRT_MAX, 0); // overflow
+TEST_ADD (short, 0, SHRT_MIN, SHRT_MIN);
+TEST_ADD (short, -1, SHRT_MIN, 0); // overflow
+TEST_ADD (short, SHRT_MIN, SHRT_MIN, 0); // overflow
+
+TEST_ADD (int, 0, 0, 0);
+TEST_ADD (int, 0, INT_MAX, INT_MAX);
+TEST_ADD (int, 1, INT_MAX, 0); // overflow
+TEST_ADD (int, INT_MAX, INT_MAX, 0); // overflow
+TEST_ADD (int, 0, INT_MIN, INT_MIN);
+TEST_ADD (int, -1, INT_MIN, 0); // overflow
+TEST_ADD (int, INT_MIN, INT_MIN, 0); // overflow
+
+TEST_ADD (long, 0, 0, 0);
+TEST_ADD (long, 0, LONG_MAX, LONG_MAX);
+TEST_ADD (long, 1, LONG_MAX, 0); // overflow
+TEST_ADD (long, LONG_MAX, LONG_MAX, 0); // overflow
+TEST_ADD (long, 0, LONG_MIN, LONG_MIN);
+TEST_ADD (long, -1, LONG_MIN, 0); // overflow
+TEST_ADD (long, LONG_MIN, LONG_MIN, 0); // overflow
+
+TEST_ADD (long long, 0, 0, 0);
+TEST_ADD (long long, 0, LLONG_MAX, LLONG_MAX);
+TEST_ADD (long long, 1, LLONG_MAX, 0); // overflow
+TEST_ADD (long long, LLONG_MAX, LLONG_MAX, 0); // overflow
+TEST_ADD (long long, 0, LLONG_MIN, LLONG_MIN);
+TEST_ADD (long long, -1, LLONG_MIN, 0); // overflow
+TEST_ADD (long long, LLONG_MIN, LLONG_MIN, 0); // overflow
+
+TEST_ADD (unsigned char, 0, 0, 0);
+TEST_ADD (unsigned char, 0, UCHAR_MAX, UCHAR_MAX);
+TEST_ADD (unsigned char, 1, UCHAR_MAX, 0); // overflow
+
+TEST_ADD (unsigned char, UCHAR_MAX, UCHAR_MAX, 0); // overflow
+TEST_ADD (unsigned short, 0, 0, 0);
+TEST_ADD (unsigned short, 0, USHRT_MAX, USHRT_MAX);
+TEST_ADD (unsigned short, 1, USHRT_MAX, 0); // overflow
+TEST_ADD (unsigned short, USHRT_MAX, USHRT_MAX, 0); // overflow
+
+TEST_ADD (unsigned, 0, 0, 0);
+TEST_ADD (unsigned, 0, UINT_MAX, UINT_MAX);
+TEST_ADD (unsigned, 1, UINT_MAX, 0); // overflow
+TEST_ADD (unsigned, UINT_MAX, UINT_MAX, 0); // overflow
+
+TEST_ADD (unsigned long, 0, 0, 0);
+TEST_ADD (unsigned long, 0, ULONG_MAX, ULONG_MAX);
+TEST_ADD (unsigned long, 1, ULONG_MAX, 0); // overflow
+TEST_ADD (unsigned long, ULONG_MAX, ULONG_MAX, 0); // overflow
+
+TEST_ADD (unsigned long long, 0, 0, 0);
+TEST_ADD (unsigned long long, 0, ULLONG_MAX, ULLONG_MAX);
+TEST_ADD (unsigned long long, 1, ULLONG_MAX, 0); // overflow
+TEST_ADD (unsigned long long, ULLONG_MAX, ULLONG_MAX, 0); // overflow
+
+
+// Make sure the built-ins are accepted in the following contexts
+// where constant expressions are required and that they return
+// the expected overflow value.
+
+namespace Enum {
+
+enum Add {
+ a0 = __builtin_add_overflow_p ( 1, 1, 0),
+ a1 = __builtin_add_overflow_p (INT_MAX, 1, 0)
+};
+
+Assert (a0 == 0);
+Assert (a1 == 1);
+
+enum Sub {
+ s0 = __builtin_sub_overflow_p ( 1, 1, 0),
+ s1 = __builtin_sub_overflow_p (INT_MIN, 1, 0)
+};
+
+Assert (s0 == 0);
+Assert (s1 == 1);
+
+enum Mul {
+ m0 = __builtin_add_overflow_p ( 1, 1, 0),
+ m1 = __builtin_add_overflow_p (INT_MAX, INT_MAX, 0)
+};
+
+Assert (m0 == 0);
+Assert (m1 == 1);
+
+} // namespace Enum
+
+namespace TemplateArg {
+
+template <class T, class U, class V,
+ T x, U y, bool v, bool z = __builtin_add_overflow_p (x, y, V ())>
+struct Add {
+ Assert (z == v);
+};
+
+template <class T, class U, class V,
+ T x, U y, bool v, bool z = __builtin_sub_overflow_p (x, y, V ())>
+struct Sub {
+ Assert (z == v);
+};
+
+template <class T, class U, class V,
+ T x, U y, bool v, bool z = __builtin_mul_overflow_p (x, y, V ())>
+struct Mul {
+ Assert (z == v);
+};
+
+template struct Add<int, int, int, 1, 1, false>;
+template struct Add<int, int, int, 1, INT_MAX, true>;
+
+template struct Sub<int, int, int, 1, 1, false>;
+template struct Sub<int, int, int, -2, INT_MAX, true>;
+
+template struct Mul<int, int, int, 1, 1, false>;
+template struct Mul<int, int, int, 2, INT_MAX / 2 + 1, true>;
+
+} // namespace TemplateArg
+
+#if __cplusplus >= 201402L
+
+namespace Initializer {
+
+struct Result {
+ int res;
+ bool vflow;
+};
+
+constexpr Result
+add_vflow (int a, int b)
+{
+#if 1
+ Result res = { a + b, __builtin_add_overflow_p (a, b, int ()) };
+#else
+ // The following fails to compile because of c++/71391 - error
+ // on aggregate initialization with side-effects in a constexpr
+ // function
+ int c = 0;
+ Result res = { 0, __builtin_add_overflow (a, b, &c) };
+ res.c = c;
+#endif
+ return res;
+}
+
+constexpr Result sum = add_vflow (123, 456);
+Assert (sum.res == 123 + 456);
+Assert (!sum.vflow);
+
+} // namespace Initializer
+
+#endif // __cplusplus >= 201402L
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice10.C
index f6fc80cdc70..51612737847 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice10.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice10.C
@@ -4,5 +4,5 @@
struct A
{
constexpr A() {}
- static constexpr A a[2] = {}; // { dg-error "incomplete" }
+ static constexpr A a[2] = {}; // { dg-error "22:elements of array 'constexpr const A A::a \\\[2\\\]' have incomplete type" }
};
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C
index 514cca59c33..7b0d83e608d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C
@@ -2,6 +2,6 @@
struct A
{
- static constexpr A a = 1; // { dg-error "incomplete" }
+ static constexpr A a = 1; // { dg-error "22:'constexpr const A A::a' has incomplete type" }
constexpr A(int i) { }
};
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn27.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn27.C
index c9291c2b8e4..b114df2fdd5 100644
--- a/gcc/testsuite/g++.dg/cpp1y/auto-fn27.C
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn27.C
@@ -31,7 +31,7 @@ F<T>::bar (const G &)
{
auto s = I;
typedef decltype (s) L;
- auto u =[&](L) { auto t = foo (J::K (), 0); }; // { dg-error "" }
+ auto u =[&](L) { auto t = foo (J::K (), 0); }; // { dg-error "25:'void t' has incomplete type" }
}
struct B {
typedef int G;
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-arith-overflow.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-arith-overflow.C
new file mode 100644
index 00000000000..7ca0033d217
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-arith-overflow.C
@@ -0,0 +1,229 @@
+// Test to exercise that the type-specific integer arithmetic built-ins
+// with overflow checking can be used in C++ 14 constant expressions.
+// -Woverflow is disabled to prevent (bogus?) G++ warnings.
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-Wno-overflow" }
+
+#define SCHAR_MAX __SCHAR_MAX__
+#define SHRT_MAX __SHRT_MAX__
+#define INT_MAX __INT_MAX__
+#define LONG_MAX __LONG_MAX__
+#define LLONG_MAX __LONG_LONG_MAX__
+
+#define SCHAR_MIN (-__SCHAR_MAX__ - 1)
+#define SHRT_MIN (-__SHRT_MAX__ - 1)
+#define INT_MIN (-__INT_MAX__ - 1)
+#define LONG_MIN (-__LONG_MAX__ - 1)
+#define LLONG_MIN (-__LONG_LONG_MAX__ - 1)
+
+#define UCHAR_MAX (SCHAR_MAX * 2U + 1)
+#define USHRT_MAX (SHRT_MAX * 2U + 1)
+#define UINT_MAX (INT_MAX * 2U + 1)
+#define ULONG_MAX (LONG_MAX * 2LU + 1)
+#define ULLONG_MAX (LLONG_MAX * 2LLU + 1)
+
+#define USCHAR_MIN (-__USCHAR_MAX__ - 1)
+#define USHRT_MIN (-__USHRT_MAX__ - 1)
+#define UINT_MIN (-__UINT_MAX__ - 1)
+#define ULONG_MIN (-__ULONG_MAX__ - 1)
+#define ULLONG_MIN (-__ULONG_LONG_MAX__ - 1)
+
+// Helper macros.
+#define sadd(x, y) ((x) + (y))
+#define saddl(x, y) ((x) + (y))
+#define saddll(x, y) ((x) + (y))
+#define uadd(x, y) ((x) + (y))
+#define uaddl(x, y) ((x) + (y))
+#define uaddll(x, y) ((x) + (y))
+#define ssub(x, y) ((x) - (y))
+#define ssubl(x, y) ((x) - (y))
+#define ssubll(x, y) ((x) - (y))
+#define usub(x, y) ((x) - (y))
+#define usubl(x, y) ((x) - (y))
+#define usubll(x, y) ((x) - (y))
+#define smul(x, y) ((x) * (y))
+#define smull(x, y) ((x) * (y))
+#define smulll(x, y) ((x) * (y))
+#define umul(x, y) ((x) * (y))
+#define umull(x, y) ((x) * (y))
+#define umulll(x, y) ((x) * (y))
+
+// Result object.
+template <class T>
+struct Res
+{
+ constexpr Res (T a, bool v): z (a), v (v) { }
+ T z; bool v;
+};
+
+template <class T>
+constexpr bool operator== (Res<T> a, Res<T> b)
+{
+ return a.z == b.z && a.v == b.v;
+}
+
+#define StaticAssert(expr) static_assert ((expr), #expr)
+
+#define CONCAT(a, b) a ## b
+#define CAT(a, b) CONCAT (a, b)
+
+// Helper to determine the type of the result of the arithmetic
+// as specified by the built-ins.
+template <class T> struct ResType { typedef T type; };
+template <> struct ResType<signed char> { typedef int type; };
+template <> struct ResType<unsigned char> { typedef unsigned type; };
+template <> struct ResType<signed short> { typedef int type; };
+template <> struct ResType<unsigned short> { typedef unsigned type; };
+
+// Macro to define a single test case verifying that integer overflow
+// is detected when expected, and when not, that the result matches
+// the result computed using ordinary arithmetic. The result cannot
+// be tested in the presence of overflow since it's not a core
+// constant expression.
+#define TEST(op, T, x, y, vflow) \
+ constexpr Res<T> CAT (op, __LINE__)(T a, T b) \
+ { \
+ ResType<T>::type c = 0; \
+ bool v = __builtin_ ## op ## _overflow (a, b, &c); \
+ return Res<T>(c, v); \
+ } \
+ StaticAssert (vflow ? CAT (op, __LINE__)(x, y).v \
+ : CAT (op, __LINE__)(x, y) == Res<T>(op (x, y), vflow))
+
+/* Signed int addition. */
+TEST (sadd, signed char, 0, 0, 0);
+TEST (sadd, signed char, 0, SCHAR_MAX, 0);
+TEST (sadd, signed char, 1, SCHAR_MAX, 0);
+TEST (sadd, signed char, SCHAR_MAX, SCHAR_MAX, 0);
+TEST (sadd, signed char, 0, SCHAR_MIN, 0);
+TEST (sadd, signed char, -1, SCHAR_MIN, 0);
+
+TEST (sadd, short, 0, 0, 0);
+TEST (sadd, short, 0, SHRT_MAX, 0);
+TEST (sadd, short, 1, SHRT_MAX, 0);
+TEST (sadd, short, SHRT_MAX, SHRT_MAX, 0);
+TEST (sadd, short, 0, SHRT_MIN, 0);
+TEST (sadd, short, -1, SHRT_MIN, 0);
+TEST (sadd, short, SHRT_MIN, SHRT_MIN, 0);
+
+TEST (sadd, int, 0, 0, 0);
+TEST (sadd, int, 0, INT_MAX, 0);
+TEST (sadd, int, 1, INT_MAX, 1);
+TEST (sadd, int, INT_MAX, INT_MAX, 1);
+TEST (sadd, int, 0, INT_MIN, 0);
+TEST (sadd, int, -1, INT_MIN, 1);
+TEST (sadd, int, INT_MIN, INT_MIN, 1);
+
+/* Signed long addition. */
+TEST (saddl, long, 0L, 0L, 0);
+TEST (saddl, long, 0L, LONG_MAX, 0);
+TEST (saddl, long, 1L, LONG_MAX, 1);
+TEST (saddl, long, LONG_MAX, LONG_MAX, 1);
+TEST (saddl, long, 0L, LONG_MIN, 0);
+TEST (saddl, long, -1L, LONG_MIN, 1);
+TEST (saddl, long, LONG_MIN, LONG_MIN, 1);
+
+TEST (saddll, long long, 0LL, 0LL, 0);
+TEST (saddll, long long, 0LL, LLONG_MAX, 0);
+TEST (saddll, long long, 1LL, LLONG_MAX, 1);
+TEST (saddll, long long, LLONG_MAX, LLONG_MAX, 1);
+TEST (saddll, long long, 0LL, LLONG_MIN, 0);
+TEST (saddll, long long, -1LL, LLONG_MIN, 1);
+TEST (saddll, long long, LLONG_MIN, LLONG_MIN, 1);
+
+/* Unsigned int addition. */
+TEST (uadd, unsigned char, 0U, 0U, 0);
+TEST (uadd, unsigned char, 0U, UCHAR_MAX, 0);
+TEST (uadd, unsigned char, 1U, UCHAR_MAX, 0);
+TEST (uadd, unsigned char, UCHAR_MAX, UCHAR_MAX, 0);
+
+TEST (uadd, unsigned short, 0U, 0U, 0);
+TEST (uadd, unsigned short, 0U, USHRT_MAX, 0);
+TEST (uadd, unsigned short, 1U, USHRT_MAX, 0);
+TEST (uadd, unsigned short, USHRT_MAX, USHRT_MAX, 0);
+
+TEST (uadd, unsigned, 0U, 0U, 0);
+TEST (uadd, unsigned, 0U, UINT_MAX, 0);
+TEST (uadd, unsigned, 1U, UINT_MAX, 1);
+TEST (uadd, unsigned, UINT_MAX, UINT_MAX, 1);
+
+/* Unsigned long addition. */
+TEST (uaddl, unsigned long, 0UL, 0UL, 0);
+TEST (uaddl, unsigned long, 0UL, ULONG_MAX, 0);
+TEST (uaddl, unsigned long, 1UL, ULONG_MAX, 1);
+TEST (uaddl, unsigned long, ULONG_MAX, ULONG_MAX, 1);
+
+TEST (uaddll, unsigned long long, 0ULL, 0ULL, 0);
+TEST (uaddll, unsigned long long, 0ULL, ULLONG_MAX, 0);
+TEST (uaddll, unsigned long long, 1ULL, ULLONG_MAX, 1);
+TEST (uaddll, unsigned long long, ULLONG_MAX, ULLONG_MAX, 1);
+
+/* Signed int subtraction. */
+TEST (ssub, signed char, 0, 0, 0);
+TEST (ssub, signed char, 0, SCHAR_MAX, 0);
+TEST (ssub, signed char, 1, SCHAR_MAX, 0);
+TEST (ssub, signed char, SCHAR_MAX, SCHAR_MAX, 0);
+TEST (ssub, signed char, 0, SCHAR_MIN, 0);
+TEST (ssub, signed char, -1, SCHAR_MIN, 0);
+
+TEST (ssub, short, 0, 0, 0);
+TEST (ssub, short, 0, SHRT_MAX, 0);
+TEST (ssub, short, 1, SHRT_MAX, 0);
+TEST (ssub, short, SHRT_MAX, SHRT_MAX, 0);
+TEST (ssub, short, 0, SHRT_MIN, 0);
+TEST (ssub, short, -1, SHRT_MIN, 0);
+TEST (ssub, short, SHRT_MIN, SHRT_MIN, 0);
+
+TEST (ssub, int, 0, 0, 0);
+TEST (ssub, int, 0, INT_MAX, 0);
+TEST (ssub, int, 1, INT_MAX, 0);
+TEST (ssub, int, INT_MAX, INT_MAX, 0);
+TEST (ssub, int, 0, INT_MIN, 1);
+TEST (ssub, int, -1, INT_MIN, 0);
+TEST (ssub, int, INT_MIN, INT_MIN, 0);
+
+/* Signed long subtraction. */
+TEST (ssubl, long, 0L, 0L, 0);
+TEST (ssubl, long, 0L, LONG_MAX, 0);
+TEST (ssubl, long, 1L, LONG_MAX, 0);
+TEST (ssubl, long, LONG_MAX, LONG_MAX, 0);
+TEST (ssubl, long, 0L, LONG_MIN, 1);
+TEST (ssubl, long, -1L, LONG_MIN, 0);
+TEST (ssubl, long, LONG_MIN, LONG_MIN, 0);
+
+/* Signed long long subtraction. */
+TEST (ssubll, long long, 0LL, 0LL, 0);
+TEST (ssubll, long long, 0LL, LLONG_MAX, 0);
+TEST (ssubll, long long, 1LL, LLONG_MAX, 0);
+TEST (ssubll, long long, LLONG_MAX, LLONG_MAX, 0);
+TEST (ssubll, long long, 0LL, LLONG_MIN, 1);
+TEST (ssubll, long long, -1LL, LLONG_MIN, 0);
+TEST (ssubll, long long, LLONG_MIN, LLONG_MIN, 0);
+
+/* Unsigned int subtraction. */
+TEST (usub, unsigned char, 0U, 0U, 0);
+TEST (usub, unsigned char, 0U, UCHAR_MAX, 1);
+TEST (usub, unsigned char, 1U, UCHAR_MAX, 1);
+TEST (usub, unsigned char, UCHAR_MAX, UCHAR_MAX, 0);
+
+TEST (usub, unsigned short, 0U, 0U, 0);
+TEST (usub, unsigned short, 0U, USHRT_MAX, 1);
+TEST (usub, unsigned short, 1U, USHRT_MAX, 1);
+TEST (usub, unsigned short, USHRT_MAX, USHRT_MAX, 0);
+
+TEST (usub, unsigned, 0U, 0U, 0);
+TEST (usub, unsigned, 0U, UINT_MAX, 1);
+TEST (usub, unsigned, 1U, UINT_MAX, 1);
+TEST (usub, unsigned, UINT_MAX, UINT_MAX, 0);
+
+/* Unsigned long subtraction. */
+TEST (usubl, unsigned long, 0UL, 0UL, 0);
+TEST (usubl, unsigned long, 0UL, ULONG_MAX, 1);
+TEST (usubl, unsigned long, 1UL, ULONG_MAX, 1);
+TEST (usubl, unsigned long, ULONG_MAX, ULONG_MAX, 0);
+
+/* Unsigned long long subtraction. */
+TEST (usubll, unsigned long long, 0ULL, 0ULL, 0);
+TEST (usubll, unsigned long long, 0ULL, ULLONG_MAX, 1);
+TEST (usubll, unsigned long long, 1ULL, ULLONG_MAX, 1);
+TEST (usubll, unsigned long long, ULLONG_MAX, ULLONG_MAX, 0);
diff --git a/gcc/testsuite/g++.dg/ext/builtin-arith-overflow-1.C b/gcc/testsuite/g++.dg/ext/builtin-arith-overflow-1.C
new file mode 100644
index 00000000000..669eea2cbd2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin-arith-overflow-1.C
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+enum A { B = 1, C = 2, D = __builtin_add_overflow_p (B, C, C) };
+int e[__builtin_add_overflow_p (B, C, C) + 1];
+template <int N> int foo (int);
+
+void
+bar ()
+{
+ foo <__builtin_add_overflow_p (B, C, C) + 1> (0);
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr35751.C b/gcc/testsuite/g++.dg/gomp/pr35751.C
index 0b6cded5929..a8acce05f51 100644
--- a/gcc/testsuite/g++.dg/gomp/pr35751.C
+++ b/gcc/testsuite/g++.dg/gomp/pr35751.C
@@ -5,8 +5,8 @@
void
foo (int i)
{
- extern int a[i]; // { dg-error "storage size of" }
- static int b[i]; // { dg-error "storage size of" }
+ extern int a[i]; // { dg-error "14:storage size of" }
+ static int b[i]; // { dg-error "14:storage size of" }
#pragma omp parallel
{
diff --git a/gcc/testsuite/g++.dg/inherit/crash5.C b/gcc/testsuite/g++.dg/inherit/crash5.C
index bce999ccbe5..5a4002e0f8a 100644
--- a/gcc/testsuite/g++.dg/inherit/crash5.C
+++ b/gcc/testsuite/g++.dg/inherit/crash5.C
@@ -1,10 +1,6 @@
-// PR c++/70202
+// PR c++/71465
-class A
-{
- virtual void foo () { }
-};
-class B : public A, A { }; // { dg-error "duplicate base type" }
-
-B b1, &b2 = b1;
-A a = b2;
+struct A { virtual void foo () {} };
+struct B : virtual A {};
+struct C : virtual A {};
+struct D : C, B, C {}; // { dg-error "duplicate base type" }
diff --git a/gcc/testsuite/g++.dg/inherit/virtual1.C b/gcc/testsuite/g++.dg/inherit/virtual1.C
index 1199b815f56..08bcbb143cf 100644
--- a/gcc/testsuite/g++.dg/inherit/virtual1.C
+++ b/gcc/testsuite/g++.dg/inherit/virtual1.C
@@ -5,8 +5,8 @@ struct A
virtual ~A() {}
};
-struct B : A, virtual A {}; // { dg-error "duplicate base" }
+struct B : A, virtual A {}; // { dg-error "duplicate base|forward declaration" }
-struct C : A, B {}; // { dg-error "duplicate base" }
+struct C : A, B {}; // { dg-error "duplicate base|invalid use" }
-C c;
+C c; // { dg-error "aggregate" }
diff --git a/gcc/testsuite/g++.dg/init/array23.C b/gcc/testsuite/g++.dg/init/array23.C
index 80ffb0a98cc..fbcd39e2c3a 100644
--- a/gcc/testsuite/g++.dg/init/array23.C
+++ b/gcc/testsuite/g++.dg/init/array23.C
@@ -3,4 +3,4 @@
// array
struct A {A();int A::* t;};
-A x[]; // { dg-error "size" }
+A x[]; // { dg-error "3:array size missing" }
diff --git a/gcc/testsuite/g++.dg/init/array42.C b/gcc/testsuite/g++.dg/init/array42.C
new file mode 100644
index 00000000000..d16a9ea11ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array42.C
@@ -0,0 +1 @@
+char a[] = ("abc"); // { dg-warning "6:array 'a' initialized by parenthesized string literal" }
diff --git a/gcc/testsuite/g++.dg/init/array43.C b/gcc/testsuite/g++.dg/init/array43.C
new file mode 100644
index 00000000000..37ef2411518
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array43.C
@@ -0,0 +1,2 @@
+int a[] = 0; // { dg-error "5:initializer fails to determine size" }
+// { dg-error "11:array must be initialized" "" { target *-*-* } 1 }
diff --git a/gcc/testsuite/g++.dg/init/array44.C b/gcc/testsuite/g++.dg/init/array44.C
new file mode 100644
index 00000000000..5643c81f218
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array44.C
@@ -0,0 +1 @@
+int a[] = { }; // { dg-error "5:zero-size array" }
diff --git a/gcc/testsuite/g++.dg/init/array45.C b/gcc/testsuite/g++.dg/init/array45.C
new file mode 100644
index 00000000000..ee4451df5ff
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array45.C
@@ -0,0 +1 @@
+int a[]; // { dg-error "5:storage size" }
diff --git a/gcc/testsuite/g++.dg/init/brace2.C b/gcc/testsuite/g++.dg/init/brace2.C
index 50dc4813954..e6307525fbf 100644
--- a/gcc/testsuite/g++.dg/init/brace2.C
+++ b/gcc/testsuite/g++.dg/init/brace2.C
@@ -3,6 +3,6 @@
int x = { 2 };
const char * y = { "hello" };
int a = 2;
-int b = { 2,3 }; // { dg-error "requires one element in initializer" }
+int b = { 2,3 }; // { dg-error "5:scalar object 'b' requires one element in initializer" }
int c = { { 2 } } ; // { dg-error "braces around scalar initializer" }
int d = {}; // { dg-error "initializer" "" { target { ! c++11 } } }
diff --git a/gcc/testsuite/g++.dg/init/brace6.C b/gcc/testsuite/g++.dg/init/brace6.C
index 0fa818c80c0..f8452351d12 100644
--- a/gcc/testsuite/g++.dg/init/brace6.C
+++ b/gcc/testsuite/g++.dg/init/brace6.C
@@ -17,8 +17,8 @@ struct D { int c; };
int main()
{
int i = { 1 };
- int j = { 1, 2 }; /* { dg-error "requires one element" } */
- A a = { 6 }; /* { dg-error "initialize" "" { target { ! c++11 } } } */
+ int j = { 1, 2 }; /* { dg-error "8:scalar object 'j' requires one element" } */
+ A a = { 6 }; /* { dg-error "6:in C\\+\\+98 'a' must be initialized" "" { target { ! c++11 } } } */
B b = { 6 }; /* { dg-error "" } */
C c = { 6 }; /* { dg-error "too many initializers" } */
D d = { 6 };
diff --git a/gcc/testsuite/g++.dg/predict-loop-exit-1.C b/gcc/testsuite/g++.dg/predict-loop-exit-1.C
index 357397f512b..88262eb9d00 100644
--- a/gcc/testsuite/g++.dg/predict-loop-exit-1.C
+++ b/gcc/testsuite/g++.dg/predict-loop-exit-1.C
@@ -9,5 +9,5 @@ void test() {
return;
}
-/* { dg-final { scan-tree-dump-times "extra loop exit heuristics:" 2 "profile_estimate"} } */
-/* { dg-final { scan-tree-dump-times "loop exit heuristics:" 3 "profile_estimate"} } */
+/* { dg-final { scan-tree-dump-times "extra loop exit heuristics of edge\[^:\]*:" 2 "profile_estimate"} } */
+/* { dg-final { scan-tree-dump-times "loop exit heuristics of edge\[^:\]*:" 3 "profile_estimate"} } */
diff --git a/gcc/testsuite/g++.dg/predict-loop-exit-2.C b/gcc/testsuite/g++.dg/predict-loop-exit-2.C
index 172fab120c8..15e9866d897 100644
--- a/gcc/testsuite/g++.dg/predict-loop-exit-2.C
+++ b/gcc/testsuite/g++.dg/predict-loop-exit-2.C
@@ -9,5 +9,5 @@ void test() {
return;
}
-/* { dg-final { scan-tree-dump-times "extra loop exit heuristics:" 1 "profile_estimate"} } */
-/* { dg-final { scan-tree-dump-times "loop exit heuristics:" 2 "profile_estimate"} } */
+/* { dg-final { scan-tree-dump-times "extra loop exit heuristics of edge\[^:\]*:" 1 "profile_estimate"} } */
+/* { dg-final { scan-tree-dump-times "loop exit heuristics of edge\[^:\]*:" 2 "profile_estimate"} } */
diff --git a/gcc/testsuite/g++.dg/predict-loop-exit-3.C b/gcc/testsuite/g++.dg/predict-loop-exit-3.C
index e6ceec80159..61af84b6f56 100644
--- a/gcc/testsuite/g++.dg/predict-loop-exit-3.C
+++ b/gcc/testsuite/g++.dg/predict-loop-exit-3.C
@@ -9,5 +9,5 @@ void test() {
return;
}
-/* { dg-final { scan-tree-dump-times "extra loop exit heuristics:" 2 "profile_estimate"} } */
-/* { dg-final { scan-tree-dump-times "loop exit heuristics:" 3 "profile_estimate"} } */
+/* { dg-final { scan-tree-dump-times "extra loop exit heuristics of edge\[^:\]*:" 2 "profile_estimate"} } */
+/* { dg-final { scan-tree-dump-times "loop exit heuristics of edge\[^:\]*:" 3 "profile_estimate"} } */
diff --git a/gcc/testsuite/g++.dg/tm/jump1.C b/gcc/testsuite/g++.dg/tm/jump1.C
index e28282dc624..a27c2011861 100644
--- a/gcc/testsuite/g++.dg/tm/jump1.C
+++ b/gcc/testsuite/g++.dg/tm/jump1.C
@@ -14,8 +14,8 @@ void f()
switch (i)
{
- synchronized { // { dg-warning "statement will never be executed" }
- ++i;
+ synchronized {
+ ++i; // { dg-warning "statement will never be executed" }
case 42: // { dg-error "" }
++i;
}