Skip to content

Commit c4d1d1a

Browse files
committed
c++: testsuite: Remove testsuite_tr1.h includes
This patch removes the testsuite_tr1.h dependency from g++.dg/ext/is_*.C tests since the header is supposed to be used only by libstdc++, not front-end. This also includes test code consistency fixes. For the record this fixes the test failures reported at https://gcc.gnu.org/pipermail/gcc-patches/2023-December/641058.html gcc/testsuite/ChangeLog: * g++.dg/ext/is_array.C: Remove testsuite_tr1.h. Add necessary definitions accordingly. Tweak macros for consistency across test codes. * g++.dg/ext/is_bounded_array.C: Likewise. * g++.dg/ext/is_function.C: Likewise. * g++.dg/ext/is_member_function_pointer.C: Likewise. * g++.dg/ext/is_member_object_pointer.C: Likewise. * g++.dg/ext/is_member_pointer.C: Likewise. * g++.dg/ext/is_object.C: Likewise. * g++.dg/ext/is_reference.C: Likewise. * g++.dg/ext/is_scoped_enum.C: Likewise. Signed-off-by: Ken Matsui <[email protected]> Reviewed-by: Patrick Palka <[email protected]> Reviewed-by: Jason Merrill <[email protected]>
1 parent 5bd5ef9 commit c4d1d1a

File tree

9 files changed

+101
-105
lines changed

9 files changed

+101
-105
lines changed

gcc/testsuite/g++.dg/ext/is_array.C

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
3+
#define SA(X) static_assert((X),#X)
44

5-
using namespace __gnu_test;
5+
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
6+
SA(TRAIT(TYPE) == EXPECT); \
7+
SA(TRAIT(const TYPE) == EXPECT); \
8+
SA(TRAIT(volatile TYPE) == EXPECT); \
9+
SA(TRAIT(const volatile TYPE) == EXPECT)
610

7-
#define SA(X) static_assert((X),#X)
8-
#define SA_TEST_CATEGORY(TRAIT, X, expect) \
9-
SA(TRAIT(X) == expect); \
10-
SA(TRAIT(const X) == expect); \
11-
SA(TRAIT(volatile X) == expect); \
12-
SA(TRAIT(const volatile X) == expect)
11+
class ClassType { };
1312

1413
SA_TEST_CATEGORY(__is_array, int[2], true);
1514
SA_TEST_CATEGORY(__is_array, int[], true);
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
4-
5-
using namespace __gnu_test;
6-
73
#define SA(X) static_assert((X),#X)
84

9-
#define SA_TEST_CONST(TRAIT, TYPE, EXPECT) \
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
106
SA(TRAIT(TYPE) == EXPECT); \
11-
SA(TRAIT(const TYPE) == EXPECT)
7+
SA(TRAIT(const TYPE) == EXPECT);
128

139
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
14-
SA(TRAIT(TYPE) == EXPECT); \
15-
SA(TRAIT(const TYPE) == EXPECT); \
16-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1713
SA(TRAIT(const volatile TYPE) == EXPECT)
1814

15+
class ClassType { };
16+
1917
SA_TEST_CATEGORY(__is_bounded_array, int[2], true);
2018
SA_TEST_CATEGORY(__is_bounded_array, int[], false);
2119
SA_TEST_CATEGORY(__is_bounded_array, int[2][3], true);
@@ -31,8 +29,8 @@ SA_TEST_CATEGORY(__is_bounded_array, ClassType[][3], false);
3129
SA_TEST_CATEGORY(__is_bounded_array, int(*)[2], false);
3230
SA_TEST_CATEGORY(__is_bounded_array, int(*)[], false);
3331
SA_TEST_CATEGORY(__is_bounded_array, int(&)[2], false);
34-
SA_TEST_CONST(__is_bounded_array, int(&)[], false);
32+
SA_TEST_FN(__is_bounded_array, int(&)[], false);
3533

3634
// Sanity check.
3735
SA_TEST_CATEGORY(__is_bounded_array, ClassType, false);
38-
SA_TEST_CONST(__is_bounded_array, void(), false);
36+
SA_TEST_FN(__is_bounded_array, void(), false);
Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
3+
#define SA(X) static_assert((X),#X)
44

5-
using namespace __gnu_test;
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
6+
SA(TRAIT(TYPE) == EXPECT); \
7+
SA(TRAIT(const TYPE) == EXPECT);
68

7-
#define SA(X) static_assert((X),#X)
89
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
9-
SA(TRAIT(TYPE) == EXPECT); \
10-
SA(TRAIT(const TYPE) == EXPECT); \
11-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1213
SA(TRAIT(const volatile TYPE) == EXPECT)
1314

15+
class ClassType { };
16+
1417
struct A
1518
{ void fn(); };
1619

@@ -22,15 +25,15 @@ struct AHolder<U T::*>
2225
{ using type = U; };
2326

2427
// Positive tests.
25-
SA(__is_function(int (int)));
26-
SA(__is_function(ClassType (ClassType)));
27-
SA(__is_function(float (int, float, int[], int&)));
28-
SA(__is_function(int (int, ...)));
29-
SA(__is_function(bool (ClassType) const));
30-
SA(__is_function(AHolder<decltype(&A::fn)>::type));
28+
SA_TEST_FN(__is_function, int (int), true);
29+
SA_TEST_FN(__is_function, ClassType (ClassType), true);
30+
SA_TEST_FN(__is_function, float (int, float, int[], int&), true);
31+
SA_TEST_FN(__is_function, int (int, ...), true);
32+
SA_TEST_FN(__is_function, bool (ClassType) const, true);
33+
SA_TEST_FN(__is_function, AHolder<decltype(&A::fn)>::type, true);
3134

3235
void fn();
33-
SA(__is_function(decltype(fn)));
36+
SA_TEST_FN(__is_function, decltype(fn), true);
3437

3538
// Negative tests.
3639
SA_TEST_CATEGORY(__is_function, int, false);
@@ -39,11 +42,15 @@ SA_TEST_CATEGORY(__is_function, int&, false);
3942
SA_TEST_CATEGORY(__is_function, void, false);
4043
SA_TEST_CATEGORY(__is_function, void*, false);
4144
SA_TEST_CATEGORY(__is_function, void**, false);
42-
SA_TEST_CATEGORY(__is_function, std::nullptr_t, false);
45+
SA_TEST_CATEGORY(__is_function, decltype(nullptr), false);
4346

47+
class AbstractClass
48+
{
49+
virtual void rotate(int) = 0;
50+
};
4451
SA_TEST_CATEGORY(__is_function, AbstractClass, false);
45-
SA(!__is_function(int(&)(int)));
46-
SA(!__is_function(int(*)(int)));
52+
SA_TEST_FN(__is_function, int(&)(int), false);
53+
SA_TEST_FN(__is_function, int(*)(int), false);
4754

4855
SA_TEST_CATEGORY(__is_function, A, false);
4956
SA_TEST_CATEGORY(__is_function, decltype(&A::fn), false);
@@ -53,6 +60,8 @@ struct FnCallOverload
5360
SA_TEST_CATEGORY(__is_function, FnCallOverload, false);
5461

5562
// Sanity check.
63+
class IncompleteClass;
64+
union IncompleteUnion;
5665
SA_TEST_CATEGORY(__is_function, ClassType, false);
5766
SA_TEST_CATEGORY(__is_function, IncompleteClass, false);
5867
SA_TEST_CATEGORY(__is_function, IncompleteUnion, false);

gcc/testsuite/g++.dg/ext/is_member_function_pointer.C

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
4-
5-
using namespace __gnu_test;
6-
73
#define SA(X) static_assert((X),#X)
84

9-
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
106
SA(TRAIT(TYPE) == EXPECT); \
117
SA(TRAIT(const TYPE) == EXPECT);
128

139
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
14-
SA(TRAIT(TYPE) == EXPECT); \
15-
SA(TRAIT(const TYPE) == EXPECT); \
16-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1713
SA(TRAIT(const volatile TYPE) == EXPECT)
1814

15+
class ClassType { };
16+
1917
// Positive tests.
2018
SA_TEST_FN(__is_member_function_pointer, int (ClassType::*) (int), true);
2119
SA_TEST_FN(__is_member_function_pointer, int (ClassType::*) (int) const, true);
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
4-
5-
using namespace __gnu_test;
6-
73
#define SA(X) static_assert((X),#X)
84

9-
#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \
10-
SA(TRAIT(TYPE) == EXPECT); \
11-
SA(TRAIT(const TYPE) == EXPECT)
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
6+
SA(TRAIT(TYPE) == EXPECT); \
7+
SA(TRAIT(const TYPE) == EXPECT);
128

139
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
14-
SA(TRAIT(TYPE) == EXPECT); \
15-
SA(TRAIT(const TYPE) == EXPECT); \
16-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1713
SA(TRAIT(const volatile TYPE) == EXPECT)
1814

15+
class ClassType { };
16+
1917
// Positive tests.
2018
SA_TEST_CATEGORY(__is_member_object_pointer, int (ClassType::*), true);
2119
SA_TEST_CATEGORY(__is_member_object_pointer, ClassType (ClassType::*), true);
2220

2321
// Negative tests.
24-
SA_TEST_NON_VOLATILE(__is_member_object_pointer, int (ClassType::*) (int), false);
25-
SA_TEST_NON_VOLATILE(__is_member_object_pointer, int (ClassType::*) (float, ...), false);
26-
SA_TEST_NON_VOLATILE(__is_member_object_pointer, ClassType (ClassType::*) (ClassType), false);
27-
SA_TEST_NON_VOLATILE(__is_member_object_pointer, float (ClassType::*) (int, float, int[], int&), false);
22+
SA_TEST_FN(__is_member_object_pointer, int (ClassType::*) (int), false);
23+
SA_TEST_FN(__is_member_object_pointer, int (ClassType::*) (float, ...), false);
24+
SA_TEST_FN(__is_member_object_pointer, ClassType (ClassType::*) (ClassType), false);
25+
SA_TEST_FN(__is_member_object_pointer, float (ClassType::*) (int, float, int[], int&), false);
2826

2927
// Sanity check.
3028
SA_TEST_CATEGORY(__is_member_object_pointer, ClassType, false);
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
4-
5-
using namespace __gnu_test;
6-
73
#define SA(X) static_assert((X),#X)
84

9-
#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \
10-
SA(TRAIT(TYPE) == EXPECT); \
11-
SA(TRAIT(const TYPE) == EXPECT)
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
6+
SA(TRAIT(TYPE) == EXPECT); \
7+
SA(TRAIT(const TYPE) == EXPECT);
128

139
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
14-
SA(TRAIT(TYPE) == EXPECT); \
15-
SA(TRAIT(const TYPE) == EXPECT); \
16-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1713
SA(TRAIT(const volatile TYPE) == EXPECT)
1814

15+
class ClassType { };
16+
1917
SA_TEST_CATEGORY(__is_member_pointer, int (ClassType::*), true);
2018
SA_TEST_CATEGORY(__is_member_pointer, ClassType (ClassType::*), true);
2119

22-
SA_TEST_NON_VOLATILE(__is_member_pointer, int (ClassType::*)(int), true);
23-
SA_TEST_NON_VOLATILE(__is_member_pointer, int (ClassType::*)(int) const, true);
24-
SA_TEST_NON_VOLATILE(__is_member_pointer, int (ClassType::*)(float, ...), true);
25-
SA_TEST_NON_VOLATILE(__is_member_pointer, ClassType (ClassType::*)(ClassType), true);
26-
SA_TEST_NON_VOLATILE(__is_member_pointer,
27-
float (ClassType::*)(int, float, int[], int&), true);
20+
SA_TEST_FN(__is_member_pointer, int (ClassType::*)(int), true);
21+
SA_TEST_FN(__is_member_pointer, int (ClassType::*)(int) const, true);
22+
SA_TEST_FN(__is_member_pointer, int (ClassType::*)(float, ...), true);
23+
SA_TEST_FN(__is_member_pointer, ClassType (ClassType::*)(ClassType), true);
24+
SA_TEST_FN(__is_member_pointer, float (ClassType::*)(int, float, int[], int&), true);
2825

2926
// Sanity check.
3027
SA_TEST_CATEGORY(__is_member_pointer, ClassType, false);

gcc/testsuite/g++.dg/ext/is_object.C

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
4-
5-
using namespace __gnu_test;
6-
73
#define SA(X) static_assert((X),#X)
84

9-
#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \
10-
SA(TRAIT(TYPE) == EXPECT); \
11-
SA(TRAIT(const TYPE) == EXPECT)
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
6+
SA(TRAIT(TYPE) == EXPECT); \
7+
SA(TRAIT(const TYPE) == EXPECT);
128

139
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
1410
SA(TRAIT(TYPE) == EXPECT); \
1511
SA(TRAIT(const TYPE) == EXPECT); \
1612
SA(TRAIT(volatile TYPE) == EXPECT); \
1713
SA(TRAIT(const volatile TYPE) == EXPECT)
1814

19-
SA_TEST_NON_VOLATILE(__is_object, int (int), false);
20-
SA_TEST_NON_VOLATILE(__is_object, ClassType (ClassType), false);
21-
SA_TEST_NON_VOLATILE(__is_object,
22-
float (int, float, int[], int&), false);
15+
class ClassType { };
16+
17+
SA_TEST_FN(__is_object, int (int), false);
18+
SA_TEST_FN(__is_object, ClassType (ClassType), false);
19+
SA_TEST_FN(__is_object, float (int, float, int[], int&), false);
2320
SA_TEST_CATEGORY(__is_object, int&, false);
2421
SA_TEST_CATEGORY(__is_object, ClassType&, false);
25-
SA_TEST_NON_VOLATILE(__is_object, int(&)(int), false);
22+
SA_TEST_FN(__is_object, int(&)(int), false);
2623
SA_TEST_CATEGORY(__is_object, void, false);
2724

2825
// Sanity check.

gcc/testsuite/g++.dg/ext/is_reference.C

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
3+
#define SA(X) static_assert((X),#X)
44

5-
using namespace __gnu_test;
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
6+
SA(TRAIT(TYPE) == EXPECT); \
7+
SA(TRAIT(const TYPE) == EXPECT);
68

7-
#define SA(X) static_assert((X),#X)
89
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
9-
SA(TRAIT(TYPE) == EXPECT); \
10-
SA(TRAIT(const TYPE) == EXPECT); \
11-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1213
SA(TRAIT(const volatile TYPE) == EXPECT)
1314

15+
class ClassType { };
16+
class IncompleteClass;
17+
1418
// Positive tests.
1519
SA_TEST_CATEGORY(__is_reference, int&, true);
1620
SA_TEST_CATEGORY(__is_reference, ClassType&, true);
17-
SA(__is_reference(int(&)(int)));
21+
SA_TEST_FN(__is_reference, int(&)(int), true);
1822
SA_TEST_CATEGORY(__is_reference, int&&, true);
1923
SA_TEST_CATEGORY(__is_reference, ClassType&&, true);
20-
SA(__is_reference(int(&&)(int)));
24+
SA_TEST_FN(__is_reference, int(&&)(int), true);
2125
SA_TEST_CATEGORY(__is_reference, IncompleteClass&, true);
2226

2327
// Negative tests
2428
SA_TEST_CATEGORY(__is_reference, void, false);
2529
SA_TEST_CATEGORY(__is_reference, int*, false);
2630
SA_TEST_CATEGORY(__is_reference, int[3], false);
27-
SA(!__is_reference(int(int)));
28-
SA(!__is_reference(int(*const)(int)));
29-
SA(!__is_reference(int(*volatile)(int)));
30-
SA(!__is_reference(int(*const volatile)(int)));
31+
SA_TEST_FN(__is_reference, int(int), false);
32+
SA_TEST_FN(__is_reference, int(*const)(int), false);
33+
SA_TEST_FN(__is_reference, int(*volatile)(int), false);
34+
SA_TEST_FN(__is_reference, int(*const volatile)(int), false);
3135

3236
// Sanity check.
3337
SA_TEST_CATEGORY(__is_reference, ClassType, false);

gcc/testsuite/g++.dg/ext/is_scoped_enum.C

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
// { dg-do compile { target c++11 } }
22

3-
#include <testsuite_tr1.h>
4-
5-
using namespace __gnu_test;
6-
73
#define SA(X) static_assert((X),#X)
84

9-
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
5+
#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \
106
SA(TRAIT(TYPE) == EXPECT); \
117
SA(TRAIT(const TYPE) == EXPECT);
128

139
#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
14-
SA(TRAIT(TYPE) == EXPECT); \
15-
SA(TRAIT(const TYPE) == EXPECT); \
16-
SA(TRAIT(volatile TYPE) == EXPECT); \
10+
SA(TRAIT(TYPE) == EXPECT); \
11+
SA(TRAIT(const TYPE) == EXPECT); \
12+
SA(TRAIT(volatile TYPE) == EXPECT); \
1713
SA(TRAIT(const volatile TYPE) == EXPECT)
1814

1915
enum class E { e1, e2 };

0 commit comments

Comments
 (0)