Added tests to make sure that the categorization traits work on incomplete types

llvm-svn: 261925
This commit is contained in:
Marshall Clow 2016-02-25 20:15:47 +00:00
parent 3095148015
commit 4877c197c2
29 changed files with 127 additions and 15 deletions

View File

@ -12,12 +12,13 @@
// array
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_array_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -46,10 +47,14 @@ void test_array()
typedef char array[3];
typedef const char const_array[3];
typedef char incomplete_array[];
struct incomplete_type;
int main()
{
test_array<array>();
test_array<const_array>();
test_array<incomplete_array>();
// LWG#2581
static_assert(!std::is_array<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// class
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_class_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -47,7 +48,12 @@ class Class
{
};
struct incomplete_type;
int main()
{
test_class<Class>();
// LWG#2581
static_assert( std::is_class<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// enum
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_enum_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -44,8 +45,12 @@ void test_enum()
}
enum Enum {zero, one};
struct incomplete_type;
int main()
{
test_enum<Enum>();
// LWG#2581
static_assert(!std::is_enum<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// floating_point
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_floating_point_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -43,9 +44,14 @@ void test_floating_point()
test_floating_point_imp<const volatile T>();
}
struct incomplete_type;
int main()
{
test_floating_point<float>();
test_floating_point<double>();
test_floating_point<long double>();
// LWG#2581
static_assert(!std::is_floating_point<incomplete_type>::value, "");
}

View File

@ -12,13 +12,14 @@
// function
#include <type_traits>
#include "test_macros.h"
using namespace std;
class Class {};
enum Enum1 {};
#if __cplusplus >= 201103L
#if TEST_STD_VER >= 11
enum class Enum2 : int {};
#else
enum Enum2 {};
@ -28,7 +29,7 @@ template <class T>
void test()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -64,6 +65,7 @@ void test()
test<__VA_ARGS__ volatile &&>(); \
test<__VA_ARGS__ const volatile &&>()
struct incomplete_type;
int main()
{
@ -75,7 +77,7 @@ int main()
TEST_REGULAR( void (int, ...) );
TEST_REGULAR( int (double, ...) );
TEST_REGULAR( int (double, char, ...) );
#if __cplusplus >= 201103L
#if TEST_STD_VER >= 11
TEST_REF_QUALIFIED( void () );
TEST_REF_QUALIFIED( void (int) );
TEST_REF_QUALIFIED( int (double) );
@ -85,4 +87,7 @@ int main()
TEST_REF_QUALIFIED( int (double, ...) );
TEST_REF_QUALIFIED( int (double, char, ...) );
#endif
// LWG#2581
static_assert(!std::is_function<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// integral
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_integral_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert( std::is_integral<T>::value, "");
@ -43,6 +44,8 @@ void test_integral()
test_integral_imp<const volatile T>();
}
struct incomplete_type;
int main()
{
test_integral<bool>();
@ -62,4 +65,7 @@ int main()
test_integral<__int128_t>();
test_integral<__uint128_t>();
#endif
// LWG#2581
static_assert(!std::is_integral<incomplete_type>::value, "");
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -89,5 +90,5 @@ int main()
test_is_not_array<Empty>();
test_is_not_array<bit_zero>();
test_is_not_array<NotEmpty>();
test_is_not_array<Abstract>();
test_is_not_array<incomplete_type>(); // LWG#2581
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -76,6 +77,7 @@ int main()
test_is_class<bit_zero>();
test_is_class<NotEmpty>();
test_is_class<Abstract>();
test_is_class<incomplete_type>();
#if TEST_STD_VER >= 11
// In C++03 we have an emulation of std::nullptr_t

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -90,4 +91,5 @@ int main()
test_is_not_enum<NotEmpty>();
test_is_not_enum<Abstract>();
test_is_not_enum<FunctionPtr>();
test_is_not_enum<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -98,4 +99,5 @@ int main()
test_is_not_floating_point<Abstract>();
test_is_not_floating_point<Enum>();
test_is_not_floating_point<FunctionPtr>();
test_is_not_floating_point<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -95,4 +96,5 @@ int main()
test_is_not_function<NotEmpty>();
test_is_not_function<Abstract>();
test_is_not_function<Abstract*>();
test_is_not_function<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -101,4 +102,5 @@ int main()
test_is_not_integral<bit_zero>();
test_is_not_integral<NotEmpty>();
test_is_not_integral<Abstract>();
test_is_not_integral<incomplete_type>();
}

View File

@ -69,6 +69,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -92,4 +93,5 @@ int main()
test_is_not_lvalue_reference<bit_zero>();
test_is_not_lvalue_reference<NotEmpty>();
test_is_not_lvalue_reference<Abstract>();
test_is_not_lvalue_reference<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -94,4 +95,5 @@ int main()
test_is_not_member_object_pointer<bit_zero>();
test_is_not_member_object_pointer<NotEmpty>();
test_is_not_member_object_pointer<Abstract>();
test_is_not_member_object_pointer<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -95,4 +96,5 @@ int main()
test_is_not_member_pointer<bit_zero>();
test_is_not_member_pointer<NotEmpty>();
test_is_not_member_pointer<Abstract>();
test_is_not_member_pointer<incomplete_type>();
}

View File

@ -69,6 +69,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -92,4 +93,5 @@ int main()
test_is_not_null_pointer<bit_zero>();
test_is_not_null_pointer<NotEmpty>();
test_is_not_null_pointer<Abstract>();
test_is_not_null_pointer<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -91,4 +92,5 @@ int main()
test_is_not_pointer<bit_zero>();
test_is_not_pointer<NotEmpty>();
test_is_not_pointer<Abstract>();
test_is_not_pointer<incomplete_type>();
}

View File

@ -69,6 +69,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -92,4 +93,5 @@ int main()
test_is_not_rvalue_reference<bit_zero>();
test_is_not_rvalue_reference<NotEmpty>();
test_is_not_rvalue_reference<Abstract>();
test_is_not_rvalue_reference<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -90,4 +91,5 @@ int main()
test_is_not_union<bit_zero>();
test_is_not_union<NotEmpty>();
test_is_not_union<Abstract>();
test_is_not_union<incomplete_type>();
}

View File

@ -67,6 +67,7 @@ class Abstract
};
enum Enum {zero, one};
struct incomplete_type;
typedef void (*FunctionPtr)();
@ -89,4 +90,5 @@ int main()
test_is_not_void<Abstract>();
test_is_not_void<Enum>();
test_is_not_void<FunctionPtr>();
test_is_not_void<incomplete_type>();
}

View File

@ -34,8 +34,13 @@ void test_lvalue_ref()
static_assert(!std::is_function<T>::value, "");
}
struct incomplete_type;
int main()
{
test_lvalue_ref<int&>();
test_lvalue_ref<const int&>();
// LWG#2581
static_assert(!std::is_lvalue_reference<incomplete_type>::value, "");
}

View File

@ -48,6 +48,8 @@ class Class
{
};
struct incomplete_type;
int main()
{
test_member_function_pointer<void (Class::*)()>();
@ -133,4 +135,7 @@ int main()
test_member_function_pointer<void (Class::*)(int,...) const volatile &&>();
test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>();
#endif
// LWG#2581
static_assert(!std::is_member_function_pointer<incomplete_type>::value, "");
}

View File

@ -48,6 +48,8 @@ class Class
{
};
struct incomplete_type;
int main()
{
test_member_function_pointer<void (Class::*)()>();
@ -73,4 +75,7 @@ int main()
test_member_function_pointer<void (Class::*)(...) volatile>();
test_member_function_pointer<void (Class::*)(int, ...) volatile>();
test_member_function_pointer<void (Class::*)(int, char, ...) volatile>();
// LWG#2581
static_assert(!std::is_member_function_pointer<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// member_object_pointer
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_member_object_pointer_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -47,7 +48,12 @@ class Class
{
};
struct incomplete_type;
int main()
{
test_member_object_pointer<int Class::*>();
// LWG#2581
static_assert(!std::is_member_object_pointer<incomplete_type>::value, "");
}

View File

@ -14,8 +14,9 @@
#include <type_traits>
#include <cstddef> // for std::nullptr_t
#include "test_macros.h"
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
template <class T>
void test_nullptr_imp()
{
@ -44,9 +45,14 @@ void test_nullptr()
test_nullptr_imp<const volatile T>();
}
struct incomplete_type;
int main()
{
test_nullptr<std::nullptr_t>();
// LWG#2581
static_assert(!std::is_null_pointer<incomplete_type>::value, "");
}
#else
int main() {}

View File

@ -12,12 +12,14 @@
// pointer
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_pointer_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -43,10 +45,15 @@ void test_pointer()
test_pointer_imp<const volatile T>();
}
struct incomplete_type;
int main()
{
test_pointer<void*>();
test_pointer<int*>();
test_pointer<const int*>();
test_pointer<void (*)(int)>();
// LWG#2581
static_assert(!std::is_pointer<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// rvalue_ref
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_rvalue_ref()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -34,10 +35,15 @@ void test_rvalue_ref()
static_assert(!std::is_function<T>::value, "");
}
struct incomplete_type;
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test_rvalue_ref<int&&>();
test_rvalue_ref<const int&&>();
// LWG#2581
static_assert(!std::is_rvalue_reference<incomplete_type>::value, "");
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -12,12 +12,13 @@
// union
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_union_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -49,7 +50,12 @@ union Union
double __;
};
struct incomplete_type;
int main()
{
test_union<Union>();
// LWG#2581
static_assert(!std::is_union<incomplete_type>::value, "");
}

View File

@ -12,12 +12,13 @@
// void
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_void_imp()
{
static_assert( std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -43,7 +44,12 @@ void test_void()
test_void_imp<const volatile T>();
}
struct incomplete_type;
int main()
{
test_void<void>();
// LWG#2581
static_assert(!std::is_void<incomplete_type>::value, "");
}