On Wed, 20 Dec 2023, Ken Matsui wrote: > 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.
LGTM > > 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 <kmat...@gcc.gnu.org> > --- > gcc/testsuite/g++.dg/ext/is_array.C | 15 ++++--- > gcc/testsuite/g++.dg/ext/is_bounded_array.C | 20 ++++----- > gcc/testsuite/g++.dg/ext/is_function.C | 41 +++++++++++-------- > .../g++.dg/ext/is_member_function_pointer.C | 14 +++---- > .../g++.dg/ext/is_member_object_pointer.C | 26 ++++++------ > gcc/testsuite/g++.dg/ext/is_member_pointer.C | 29 ++++++------- > gcc/testsuite/g++.dg/ext/is_object.C | 21 ++++------ > gcc/testsuite/g++.dg/ext/is_reference.C | 28 +++++++------ > gcc/testsuite/g++.dg/ext/is_scoped_enum.C | 12 ++---- > 9 files changed, 101 insertions(+), 105 deletions(-) > > diff --git a/gcc/testsuite/g++.dg/ext/is_array.C > b/gcc/testsuite/g++.dg/ext/is_array.C > index facfed5c7cb..f1a6e08b87a 100644 > --- a/gcc/testsuite/g++.dg/ext/is_array.C > +++ b/gcc/testsuite/g++.dg/ext/is_array.C > @@ -1,15 +1,14 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > +#define SA(X) static_assert((X),#X) > > -using namespace __gnu_test; > +#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(const volatile TYPE) == EXPECT) > > -#define SA(X) static_assert((X),#X) > -#define SA_TEST_CATEGORY(TRAIT, X, expect) \ > - SA(TRAIT(X) == expect); \ > - SA(TRAIT(const X) == expect); \ > - SA(TRAIT(volatile X) == expect); \ > - SA(TRAIT(const volatile X) == expect) > +class ClassType { }; > > SA_TEST_CATEGORY(__is_array, int[2], true); > SA_TEST_CATEGORY(__is_array, int[], true); > diff --git a/gcc/testsuite/g++.dg/ext/is_bounded_array.C > b/gcc/testsuite/g++.dg/ext/is_bounded_array.C > index 346790eba12..b5fe435de95 100644 > --- a/gcc/testsuite/g++.dg/ext/is_bounded_array.C > +++ b/gcc/testsuite/g++.dg/ext/is_bounded_array.C > @@ -1,21 +1,19 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > - > -using namespace __gnu_test; > - > #define SA(X) static_assert((X),#X) > > -#define SA_TEST_CONST(TRAIT, TYPE, EXPECT) \ > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT) > + SA(TRAIT(const TYPE) == EXPECT); > > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > +class ClassType { }; > + > SA_TEST_CATEGORY(__is_bounded_array, int[2], true); > SA_TEST_CATEGORY(__is_bounded_array, int[], false); > SA_TEST_CATEGORY(__is_bounded_array, int[2][3], true); > @@ -31,8 +29,8 @@ SA_TEST_CATEGORY(__is_bounded_array, ClassType[][3], false); > SA_TEST_CATEGORY(__is_bounded_array, int(*)[2], false); > SA_TEST_CATEGORY(__is_bounded_array, int(*)[], false); > SA_TEST_CATEGORY(__is_bounded_array, int(&)[2], false); > -SA_TEST_CONST(__is_bounded_array, int(&)[], false); > +SA_TEST_FN(__is_bounded_array, int(&)[], false); > > // Sanity check. > SA_TEST_CATEGORY(__is_bounded_array, ClassType, false); > -SA_TEST_CONST(__is_bounded_array, void(), false); > +SA_TEST_FN(__is_bounded_array, void(), false); > diff --git a/gcc/testsuite/g++.dg/ext/is_function.C > b/gcc/testsuite/g++.dg/ext/is_function.C > index 2e1594b12ad..1fc3c96df1f 100644 > --- a/gcc/testsuite/g++.dg/ext/is_function.C > +++ b/gcc/testsuite/g++.dg/ext/is_function.C > @@ -1,16 +1,19 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > +#define SA(X) static_assert((X),#X) > > -using namespace __gnu_test; > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); > > -#define SA(X) static_assert((X),#X) > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > +class ClassType { }; > + > struct A > { void fn(); }; > > @@ -22,15 +25,15 @@ struct AHolder<U T::*> > { using type = U; }; > > // Positive tests. > -SA(__is_function(int (int))); > -SA(__is_function(ClassType (ClassType))); > -SA(__is_function(float (int, float, int[], int&))); > -SA(__is_function(int (int, ...))); > -SA(__is_function(bool (ClassType) const)); > -SA(__is_function(AHolder<decltype(&A::fn)>::type)); > +SA_TEST_FN(__is_function, int (int), true); > +SA_TEST_FN(__is_function, ClassType (ClassType), true); > +SA_TEST_FN(__is_function, float (int, float, int[], int&), true); > +SA_TEST_FN(__is_function, int (int, ...), true); > +SA_TEST_FN(__is_function, bool (ClassType) const, true); > +SA_TEST_FN(__is_function, AHolder<decltype(&A::fn)>::type, true); > > void fn(); > -SA(__is_function(decltype(fn))); > +SA_TEST_FN(__is_function, decltype(fn), true); > > // Negative tests. > SA_TEST_CATEGORY(__is_function, int, false); > @@ -39,11 +42,15 @@ SA_TEST_CATEGORY(__is_function, int&, false); > SA_TEST_CATEGORY(__is_function, void, false); > SA_TEST_CATEGORY(__is_function, void*, false); > SA_TEST_CATEGORY(__is_function, void**, false); > -SA_TEST_CATEGORY(__is_function, std::nullptr_t, false); > +SA_TEST_CATEGORY(__is_function, decltype(nullptr), false); > > +class AbstractClass > +{ > + virtual void rotate(int) = 0; > +}; > SA_TEST_CATEGORY(__is_function, AbstractClass, false); > -SA(!__is_function(int(&)(int))); > -SA(!__is_function(int(*)(int))); > +SA_TEST_FN(__is_function, int(&)(int), false); > +SA_TEST_FN(__is_function, int(*)(int), false); > > SA_TEST_CATEGORY(__is_function, A, false); > SA_TEST_CATEGORY(__is_function, decltype(&A::fn), false); > @@ -53,6 +60,8 @@ struct FnCallOverload > SA_TEST_CATEGORY(__is_function, FnCallOverload, false); > > // Sanity check. > +class IncompleteClass; > +union IncompleteUnion; > SA_TEST_CATEGORY(__is_function, ClassType, false); > SA_TEST_CATEGORY(__is_function, IncompleteClass, false); > SA_TEST_CATEGORY(__is_function, IncompleteUnion, false); > diff --git a/gcc/testsuite/g++.dg/ext/is_member_function_pointer.C > b/gcc/testsuite/g++.dg/ext/is_member_function_pointer.C > index 555123e8f07..4435a65d1a1 100644 > --- a/gcc/testsuite/g++.dg/ext/is_member_function_pointer.C > +++ b/gcc/testsuite/g++.dg/ext/is_member_function_pointer.C > @@ -1,21 +1,19 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > - > -using namespace __gnu_test; > - > #define SA(X) static_assert((X),#X) > > -#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > SA(TRAIT(TYPE) == EXPECT); \ > SA(TRAIT(const TYPE) == EXPECT); > > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > +class ClassType { }; > + > // Positive tests. > SA_TEST_FN(__is_member_function_pointer, int (ClassType::*) (int), true); > SA_TEST_FN(__is_member_function_pointer, int (ClassType::*) (int) const, > true); > diff --git a/gcc/testsuite/g++.dg/ext/is_member_object_pointer.C > b/gcc/testsuite/g++.dg/ext/is_member_object_pointer.C > index 835e48c8f8e..2d01febe9d4 100644 > --- a/gcc/testsuite/g++.dg/ext/is_member_object_pointer.C > +++ b/gcc/testsuite/g++.dg/ext/is_member_object_pointer.C > @@ -1,30 +1,28 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > - > -using namespace __gnu_test; > - > #define SA(X) static_assert((X),#X) > > -#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT) > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); > > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > +class ClassType { }; > + > // Positive tests. > SA_TEST_CATEGORY(__is_member_object_pointer, int (ClassType::*), true); > SA_TEST_CATEGORY(__is_member_object_pointer, ClassType (ClassType::*), true); > > // Negative tests. > -SA_TEST_NON_VOLATILE(__is_member_object_pointer, int (ClassType::*) (int), > false); > -SA_TEST_NON_VOLATILE(__is_member_object_pointer, int (ClassType::*) (float, > ...), false); > -SA_TEST_NON_VOLATILE(__is_member_object_pointer, ClassType (ClassType::*) > (ClassType), false); > -SA_TEST_NON_VOLATILE(__is_member_object_pointer, float (ClassType::*) (int, > float, int[], int&), false); > +SA_TEST_FN(__is_member_object_pointer, int (ClassType::*) (int), false); > +SA_TEST_FN(__is_member_object_pointer, int (ClassType::*) (float, ...), > false); > +SA_TEST_FN(__is_member_object_pointer, ClassType (ClassType::*) (ClassType), > false); > +SA_TEST_FN(__is_member_object_pointer, float (ClassType::*) (int, float, > int[], int&), false); > > // Sanity check. > SA_TEST_CATEGORY(__is_member_object_pointer, ClassType, false); > diff --git a/gcc/testsuite/g++.dg/ext/is_member_pointer.C > b/gcc/testsuite/g++.dg/ext/is_member_pointer.C > index 7ee2e3ab90c..c6ecbe3eee1 100644 > --- a/gcc/testsuite/g++.dg/ext/is_member_pointer.C > +++ b/gcc/testsuite/g++.dg/ext/is_member_pointer.C > @@ -1,30 +1,27 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > - > -using namespace __gnu_test; > - > #define SA(X) static_assert((X),#X) > > -#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT) > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); > > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > +class ClassType { }; > + > SA_TEST_CATEGORY(__is_member_pointer, int (ClassType::*), true); > SA_TEST_CATEGORY(__is_member_pointer, ClassType (ClassType::*), true); > > -SA_TEST_NON_VOLATILE(__is_member_pointer, int (ClassType::*)(int), true); > -SA_TEST_NON_VOLATILE(__is_member_pointer, int (ClassType::*)(int) const, > true); > -SA_TEST_NON_VOLATILE(__is_member_pointer, int (ClassType::*)(float, ...), > true); > -SA_TEST_NON_VOLATILE(__is_member_pointer, ClassType > (ClassType::*)(ClassType), true); > -SA_TEST_NON_VOLATILE(__is_member_pointer, > - float (ClassType::*)(int, float, int[], int&), true); > +SA_TEST_FN(__is_member_pointer, int (ClassType::*)(int), true); > +SA_TEST_FN(__is_member_pointer, int (ClassType::*)(int) const, true); > +SA_TEST_FN(__is_member_pointer, int (ClassType::*)(float, ...), true); > +SA_TEST_FN(__is_member_pointer, ClassType (ClassType::*)(ClassType), true); > +SA_TEST_FN(__is_member_pointer, float (ClassType::*)(int, float, int[], > int&), true); > > // Sanity check. > SA_TEST_CATEGORY(__is_member_pointer, ClassType, false); > diff --git a/gcc/testsuite/g++.dg/ext/is_object.C > b/gcc/testsuite/g++.dg/ext/is_object.C > index 5c759a5ef69..7e66b6a85a3 100644 > --- a/gcc/testsuite/g++.dg/ext/is_object.C > +++ b/gcc/testsuite/g++.dg/ext/is_object.C > @@ -1,14 +1,10 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > - > -using namespace __gnu_test; > - > #define SA(X) static_assert((X),#X) > > -#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT) > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); > > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > SA(TRAIT(TYPE) == EXPECT); \ > @@ -16,13 +12,14 @@ using namespace __gnu_test; > SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > -SA_TEST_NON_VOLATILE(__is_object, int (int), false); > -SA_TEST_NON_VOLATILE(__is_object, ClassType (ClassType), false); > -SA_TEST_NON_VOLATILE(__is_object, > - float (int, float, int[], int&), false); > +class ClassType { }; > + > +SA_TEST_FN(__is_object, int (int), false); > +SA_TEST_FN(__is_object, ClassType (ClassType), false); > +SA_TEST_FN(__is_object, float (int, float, int[], int&), false); > SA_TEST_CATEGORY(__is_object, int&, false); > SA_TEST_CATEGORY(__is_object, ClassType&, false); > -SA_TEST_NON_VOLATILE(__is_object, int(&)(int), false); > +SA_TEST_FN(__is_object, int(&)(int), false); > SA_TEST_CATEGORY(__is_object, void, false); > > // Sanity check. > diff --git a/gcc/testsuite/g++.dg/ext/is_reference.C > b/gcc/testsuite/g++.dg/ext/is_reference.C > index b5ce4db7afd..88dd3bfc1b5 100644 > --- a/gcc/testsuite/g++.dg/ext/is_reference.C > +++ b/gcc/testsuite/g++.dg/ext/is_reference.C > @@ -1,33 +1,37 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > +#define SA(X) static_assert((X),#X) > > -using namespace __gnu_test; > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); > > -#define SA(X) static_assert((X),#X) > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > +class ClassType { }; > +class IncompleteClass; > + > // Positive tests. > SA_TEST_CATEGORY(__is_reference, int&, true); > SA_TEST_CATEGORY(__is_reference, ClassType&, true); > -SA(__is_reference(int(&)(int))); > +SA_TEST_FN(__is_reference, int(&)(int), true); > SA_TEST_CATEGORY(__is_reference, int&&, true); > SA_TEST_CATEGORY(__is_reference, ClassType&&, true); > -SA(__is_reference(int(&&)(int))); > +SA_TEST_FN(__is_reference, int(&&)(int), true); > SA_TEST_CATEGORY(__is_reference, IncompleteClass&, true); > > // Negative tests > SA_TEST_CATEGORY(__is_reference, void, false); > SA_TEST_CATEGORY(__is_reference, int*, false); > SA_TEST_CATEGORY(__is_reference, int[3], false); > -SA(!__is_reference(int(int))); > -SA(!__is_reference(int(*const)(int))); > -SA(!__is_reference(int(*volatile)(int))); > -SA(!__is_reference(int(*const volatile)(int))); > +SA_TEST_FN(__is_reference, int(int), false); > +SA_TEST_FN(__is_reference, int(*const)(int), false); > +SA_TEST_FN(__is_reference, int(*volatile)(int), false); > +SA_TEST_FN(__is_reference, int(*const volatile)(int), false); > > // Sanity check. > SA_TEST_CATEGORY(__is_reference, ClassType, false); > diff --git a/gcc/testsuite/g++.dg/ext/is_scoped_enum.C > b/gcc/testsuite/g++.dg/ext/is_scoped_enum.C > index a563b6ee67d..fdf36c68fe9 100644 > --- a/gcc/testsuite/g++.dg/ext/is_scoped_enum.C > +++ b/gcc/testsuite/g++.dg/ext/is_scoped_enum.C > @@ -1,19 +1,15 @@ > // { dg-do compile { target c++11 } } > > -#include <testsuite_tr1.h> > - > -using namespace __gnu_test; > - > #define SA(X) static_assert((X),#X) > > -#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > +#define SA_TEST_FN(TRAIT, TYPE, EXPECT) \ > SA(TRAIT(TYPE) == EXPECT); \ > SA(TRAIT(const TYPE) == EXPECT); > > #define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ > - SA(TRAIT(TYPE) == EXPECT); \ > - SA(TRAIT(const TYPE) == EXPECT); \ > - SA(TRAIT(volatile TYPE) == EXPECT); \ > + SA(TRAIT(TYPE) == EXPECT); \ > + SA(TRAIT(const TYPE) == EXPECT); \ > + SA(TRAIT(volatile TYPE) == EXPECT); \ > SA(TRAIT(const volatile TYPE) == EXPECT) > > enum class E { e1, e2 }; > -- > 2.43.0 > >