summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/type-traits.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
committerdim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
commitc72c57c9e9b69944e3e009cd5e209634839581d3 (patch)
tree4fc2f184c499d106f29a386c452b49e5197bf63d /test/SemaCXX/type-traits.cpp
parent5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff)
downloadFreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip
FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'test/SemaCXX/type-traits.cpp')
-rw-r--r--test/SemaCXX/type-traits.cpp122
1 files changed, 119 insertions, 3 deletions
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 54294bc..aa18ff4 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -39,9 +39,34 @@ struct DerivesEmpty : Empty {};
struct HasCons { HasCons(int); };
struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
+struct HasNoThrowMoveAssign {
+ HasNoThrowMoveAssign& operator=(
+ const HasNoThrowMoveAssign&&) throw(); };
+struct HasNoExceptNoThrowMoveAssign {
+ HasNoExceptNoThrowMoveAssign& operator=(
+ const HasNoExceptNoThrowMoveAssign&&) noexcept;
+};
+struct HasThrowMoveAssign {
+ HasThrowMoveAssign& operator=(
+ const HasThrowMoveAssign&&) throw(POD); };
+struct HasNoExceptFalseMoveAssign {
+ HasNoExceptFalseMoveAssign& operator=(
+ const HasNoExceptFalseMoveAssign&&) noexcept(false); };
+struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
+struct HasMemberMoveCtor { HasMoveCtor member; };
+struct HasMemberMoveAssign { HasMoveAssign member; };
+struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
+struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
+struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
+struct HasMemberNoExceptFalseMoveAssign {
+ HasNoExceptFalseMoveAssign member; };
+struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
+struct HasMemberNoExceptNoThrowMoveAssign {
+ HasNoExceptNoThrowMoveAssign member; };
+
struct HasDefaultTrivialCopyAssign {
- HasDefaultTrivialCopyAssign &operator =(const HasDefaultTrivialCopyAssign&)
- = default;
+ HasDefaultTrivialCopyAssign &operator=(
+ const HasDefaultTrivialCopyAssign&) = default;
};
struct TrivialMoveButNotCopy {
TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
@@ -69,6 +94,7 @@ struct DerivesHasPriv : HasPriv {};
struct DerivesHasProt : HasProt {};
struct DerivesHasRef : HasRef {};
struct DerivesHasVirt : HasVirt {};
+struct DerivesHasMoveCtor : HasMoveCtor {};
struct HasNoThrowCopyAssign {
void operator =(const HasNoThrowCopyAssign&) throw();
@@ -165,7 +191,7 @@ typedef Empty EmptyAr[10];
struct Bit0 { int : 0; };
struct Bit0Cons { int : 0; Bit0Cons(); };
struct BitOnly { int x : 3; };
-//struct DerivesVirt : virtual POD {};
+struct DerivesVirt : virtual POD {};
void is_empty()
{
@@ -941,6 +967,19 @@ struct AllDefaulted {
~AllDefaulted() = default;
};
+struct NoDefaultMoveAssignDueToUDCopyCtor {
+ NoDefaultMoveAssignDueToUDCopyCtor(const NoDefaultMoveAssignDueToUDCopyCtor&);
+};
+
+struct NoDefaultMoveAssignDueToUDCopyAssign {
+ NoDefaultMoveAssignDueToUDCopyAssign& operator=(
+ const NoDefaultMoveAssignDueToUDCopyAssign&);
+};
+
+struct NoDefaultMoveAssignDueToDtor {
+ ~NoDefaultMoveAssignDueToDtor();
+};
+
struct AllDeleted {
AllDeleted() = delete;
AllDeleted(const AllDeleted &) = delete;
@@ -1203,6 +1242,32 @@ void has_trivial_default_constructor() {
{ int arr[F(__has_trivial_constructor(ExtDefaulted))]; }
}
+void has_trivial_move_constructor() {
+ // n3376 12.8 [class.copy]/12
+ // A copy/move constructor for class X is trivial if it is not
+ // user-provided, its declared parameter type is the same as
+ // if it had been implicitly declared, and if
+ // � class X has no virtual functions (10.3) and no virtual
+ // base classes (10.1), and
+ // � the constructor selected to copy/move each direct base
+ // class subobject is trivial, and
+ // � for each non-static data member of X that is of class
+ // type (or array thereof), the constructor selected
+ // to copy/move that member is trivial;
+ // otherwise the copy/move constructor is non-trivial.
+ { int arr[T(__has_trivial_move_constructor(POD))]; }
+ { int arr[T(__has_trivial_move_constructor(Union))]; }
+ { int arr[T(__has_trivial_move_constructor(HasCons))]; }
+ { int arr[T(__has_trivial_move_constructor(HasStaticMemberMoveCtor))]; }
+ { int arr[T(__has_trivial_move_constructor(AllDeleted))]; }
+
+ { int arr[F(__has_trivial_move_constructor(HasVirt))]; }
+ { int arr[F(__has_trivial_move_constructor(DerivesVirt))]; }
+ { int arr[F(__has_trivial_move_constructor(HasMoveCtor))]; }
+ { int arr[F(__has_trivial_move_constructor(DerivesHasMoveCtor))]; }
+ { int arr[F(__has_trivial_move_constructor(HasMemberMoveCtor))]; }
+}
+
void has_trivial_copy_constructor() {
{ int arr[T(__has_trivial_copy(Int))]; }
{ int arr[T(__has_trivial_copy(IntAr))]; }
@@ -1224,6 +1289,7 @@ void has_trivial_copy_constructor() {
{ int arr[T(__has_trivial_copy(AllDefaulted))]; }
{ int arr[T(__has_trivial_copy(AllDeleted))]; }
{ int arr[T(__has_trivial_copy(DerivesAr))]; }
+ { int arr[T(__has_trivial_copy(DerivesHasRef))]; }
{ int arr[F(__has_trivial_copy(HasCopy))]; }
{ int arr[F(__has_trivial_copy(HasTemplateCons))]; }
@@ -1251,6 +1317,7 @@ void has_trivial_copy_assignment() {
{ int arr[T(__has_trivial_assign(AllDefaulted))]; }
{ int arr[T(__has_trivial_assign(AllDeleted))]; }
{ int arr[T(__has_trivial_assign(DerivesAr))]; }
+ { int arr[T(__has_trivial_assign(DerivesHasRef))]; }
{ int arr[F(__has_trivial_assign(IntRef))]; }
{ int arr[F(__has_trivial_assign(HasCopyAssign))]; }
@@ -1286,6 +1353,7 @@ void has_trivial_destructor() {
{ int arr[T(__has_trivial_destructor(VirtAr))]; }
{ int arr[T(__has_trivial_destructor(AllDefaulted))]; }
{ int arr[T(__has_trivial_destructor(AllDeleted))]; }
+ { int arr[T(__has_trivial_destructor(DerivesHasRef))]; }
{ int arr[F(__has_trivial_destructor(HasDest))]; }
{ int arr[F(__has_trivial_destructor(void))]; }
@@ -1352,6 +1420,54 @@ void has_nothrow_assign() {
{ int arr[F(__has_nothrow_assign(PR11110))]; }
}
+void has_nothrow_move_assign() {
+ { int arr[T(__has_nothrow_move_assign(Int))]; }
+ { int arr[T(__has_nothrow_move_assign(Enum))]; }
+ { int arr[T(__has_nothrow_move_assign(Int*))]; }
+ { int arr[T(__has_nothrow_move_assign(Enum POD::*))]; }
+ { int arr[T(__has_nothrow_move_assign(POD))]; }
+ { int arr[T(__has_nothrow_move_assign(HasPriv))]; }
+ { int arr[T(__has_nothrow_move_assign(HasNoThrowMoveAssign))]; }
+ { int arr[T(__has_nothrow_move_assign(HasNoExceptNoThrowMoveAssign))]; }
+ { int arr[T(__has_nothrow_move_assign(HasMemberNoThrowMoveAssign))]; }
+ { int arr[T(__has_nothrow_move_assign(HasMemberNoExceptNoThrowMoveAssign))]; }
+ { int arr[T(__has_nothrow_move_assign(AllDeleted))]; }
+
+
+ { int arr[F(__has_nothrow_move_assign(HasThrowMoveAssign))]; }
+ { int arr[F(__has_nothrow_move_assign(HasNoExceptFalseMoveAssign))]; }
+ { int arr[F(__has_nothrow_move_assign(HasMemberThrowMoveAssign))]; }
+ { int arr[F(__has_nothrow_move_assign(HasMemberNoExceptFalseMoveAssign))]; }
+ { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; }
+ { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; }
+ { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToDtor))]; }
+}
+
+void has_trivial_move_assign() {
+ // n3376 12.8 [class.copy]/25
+ // A copy/move assignment operator for class X is trivial if it
+ // is not user-provided, its declared parameter type is the same
+ // as if it had been implicitly declared, and if:
+ // � class X has no virtual functions (10.3) and no virtual base
+ // classes (10.1), and
+ // � the assignment operator selected to copy/move each direct
+ // base class subobject is trivial, and
+ // � for each non-static data member of X that is of class type
+ // (or array thereof), the assignment operator
+ // selected to copy/move that member is trivial;
+ { int arr[T(__has_trivial_move_assign(Int))]; }
+ { int arr[T(__has_trivial_move_assign(HasStaticMemberMoveAssign))]; }
+ { int arr[T(__has_trivial_move_assign(AllDeleted))]; }
+
+ { int arr[F(__has_trivial_move_assign(HasVirt))]; }
+ { int arr[F(__has_trivial_move_assign(DerivesVirt))]; }
+ { int arr[F(__has_trivial_move_assign(HasMoveAssign))]; }
+ { int arr[F(__has_trivial_move_assign(DerivesHasMoveAssign))]; }
+ { int arr[F(__has_trivial_move_assign(HasMemberMoveAssign))]; }
+ { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; }
+ { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; }
+}
+
void has_nothrow_copy() {
{ int arr[T(__has_nothrow_copy(Int))]; }
{ int arr[T(__has_nothrow_copy(IntAr))]; }
OpenPOWER on IntegriCloud