diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Index/annotate-tokens-cxx0x.cpp | 11 | ||||
-rw-r--r-- | test/PCH/cxx-traits.cpp | 9 | ||||
-rw-r--r-- | test/PCH/cxx-traits.h | 5 | ||||
-rw-r--r-- | test/SemaCXX/type-traits.cpp | 56 |
4 files changed, 77 insertions, 4 deletions
diff --git a/test/Index/annotate-tokens-cxx0x.cpp b/test/Index/annotate-tokens-cxx0x.cpp index 89876b28ea..a126b85127 100644 --- a/test/Index/annotate-tokens-cxx0x.cpp +++ b/test/Index/annotate-tokens-cxx0x.cpp @@ -6,6 +6,11 @@ int f(Args ...args) { void test() { int a; decltype(a) b; + + typedef int Integer; + typedef float Float; + typedef bool Bool; + bool b2 = __is_trivially_constructible(Integer, Float, Bool); } // RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s @@ -14,3 +19,9 @@ void test() { // RUN: c-index-test -test-annotate-tokens=%s:8:1:9:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-DECLTYPE %s // CHECK-DECLTYPE: Identifier: "a" [8:12 - 8:13] DeclRefExpr=a:7:7 + +// RUN: c-index-test -test-annotate-tokens=%s:13:1:14:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-TRAIT %s +// CHECK-TRAIT: Identifier: "Integer" [13:42 - 13:49] TypeRef=Integer:10:15 +// CHECK-TRAIT: Identifier: "Float" [13:51 - 13:56] TypeRef=Float:11:17 +// CHECK-TRAIT: Identifier: "Bool" [13:58 - 13:62] TypeRef=Bool:12:16 + diff --git a/test/PCH/cxx-traits.cpp b/test/PCH/cxx-traits.cpp index 69c64758ae..3df34794f2 100644 --- a/test/PCH/cxx-traits.cpp +++ b/test/PCH/cxx-traits.cpp @@ -1,8 +1,11 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/cxx-traits.h -fsyntax-only -verify %s +// RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s -// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-traits.h -// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h +// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s bool _Is_pod_comparator = __is_pod<int>::__value; bool _Is_empty_check = __is_empty<int>::__value; + +bool default_construct_int = is_trivially_constructible<int>::value; +bool copy_construct_int = is_trivially_constructible<int, const int&>::value; diff --git a/test/PCH/cxx-traits.h b/test/PCH/cxx-traits.h index 62722ab179..8b62002789 100644 --- a/test/PCH/cxx-traits.h +++ b/test/PCH/cxx-traits.h @@ -9,3 +9,8 @@ template<typename _Tp> struct __is_empty { enum { __value }; }; + +template<typename T, typename ...Args> +struct is_trivially_constructible { + static const bool value = __is_trivially_constructible(T, Args...); +}; diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp index 50c135d0b7..fd41c17ab2 100644 --- a/test/SemaCXX/type-traits.cpp +++ b/test/SemaCXX/type-traits.cpp @@ -47,6 +47,10 @@ struct TrivialMoveButNotCopy { TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default; TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&); }; +struct NonTrivialDefault { + NonTrivialDefault(); +}; + struct HasDest { ~HasDest(); }; class HasPriv { int priv; }; class HasProt { protected: int prot; }; @@ -104,6 +108,10 @@ class AllPrivate { ~AllPrivate() throw(); }; +struct ThreeArgCtor { + ThreeArgCtor(int*, char*, int); +}; + void is_pod() { { int arr[T(__is_pod(int))]; } @@ -1602,7 +1610,7 @@ void is_trivial() { int arr[F(__is_trivial(cvoid))]; } } -void is_trivially_copyable() +void trivial_checks() { { int arr[T(__is_trivially_copyable(int))]; } { int arr[T(__is_trivially_copyable(Enum))]; } @@ -1646,6 +1654,25 @@ void is_trivially_copyable() { int arr[F(__is_trivially_copyable(void))]; } { int arr[F(__is_trivially_copyable(cvoid))]; } + { int arr[T((__is_trivially_constructible(int)))]; } + { int arr[T((__is_trivially_constructible(int, int)))]; } + { int arr[T((__is_trivially_constructible(int, float)))]; } + { int arr[T((__is_trivially_constructible(int, int&)))]; } + { int arr[T((__is_trivially_constructible(int, const int&)))]; } + { int arr[T((__is_trivially_constructible(int, int)))]; } + { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; } + { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; } + { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; } + { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; } + { int arr[T((__is_trivially_constructible(NonTrivialDefault, + const NonTrivialDefault&)))]; } + { int arr[T((__is_trivially_constructible(NonTrivialDefault, + NonTrivialDefault&&)))]; } + + { int arr[F((__is_trivially_constructible(int, int*)))]; } + { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; } + { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; } + { int arr[T((__is_trivially_assignable(int&, int)))]; } { int arr[T((__is_trivially_assignable(int&, int&)))]; } { int arr[T((__is_trivially_assignable(int&, int&&)))]; } @@ -1680,6 +1707,33 @@ void is_trivially_copyable() TrivialMoveButNotCopy&&)))]; } } +// Instantiation of __is_trivially_constructible +template<typename T, typename ...Args> +struct is_trivially_constructible { + static const bool value = __is_trivially_constructible(T, Args...); +}; + +void is_trivially_constructible_test() { + { int arr[T((is_trivially_constructible<int>::value))]; } + { int arr[T((is_trivially_constructible<int, int>::value))]; } + { int arr[T((is_trivially_constructible<int, float>::value))]; } + { int arr[T((is_trivially_constructible<int, int&>::value))]; } + { int arr[T((is_trivially_constructible<int, const int&>::value))]; } + { int arr[T((is_trivially_constructible<int, int>::value))]; } + { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; } + { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; } + { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; } + { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; } + { int arr[T((is_trivially_constructible<NonTrivialDefault, + const NonTrivialDefault&>::value))]; } + { int arr[T((is_trivially_constructible<NonTrivialDefault, + NonTrivialDefault&&>::value))]; } + + { int arr[F((is_trivially_constructible<int, int*>::value))]; } + { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; } + { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; } +} + void array_rank() { int t01[T(__array_rank(IntAr) == 1)]; int t02[T(__array_rank(ConstIntArAr) == 2)]; |