diff options
Diffstat (limited to 'test/SemaTemplate/address-spaces.cpp')
-rw-r--r-- | test/SemaTemplate/address-spaces.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/SemaTemplate/address-spaces.cpp b/test/SemaTemplate/address-spaces.cpp index 26e7224184..df262e1dc6 100644 --- a/test/SemaTemplate/address-spaces.cpp +++ b/test/SemaTemplate/address-spaces.cpp @@ -31,7 +31,21 @@ int check_remove0[is_same<remove_pointer<int_1_ptr>::type, int_1>::value? 1 : -1 int check_remove1[is_same<remove_pointer<int_2_ptr>::type, int_2>::value? 1 : -1]; int check_remove2[is_same<remove_pointer<int_2_ptr>::type, int>::value? -1 : 1]; int check_remove3[is_same<remove_pointer<int_2_ptr>::type, int_1>::value? -1 : 1]; + +template<typename T> +struct is_pointer_in_address_space_1 { + static const bool value = false; +}; + +template<typename T> +struct is_pointer_in_address_space_1<T __attribute__((address_space(1))) *> { + static const bool value = true; +}; +int check_ptr_in_as1[is_pointer_in_address_space_1<int_1_ptr>::value? 1 : -1]; +int check_ptr_in_as2[is_pointer_in_address_space_1<int_2_ptr>::value? -1 : 1]; +int check_ptr_in_as3[is_pointer_in_address_space_1<int*>::value? -1 : 1]; + // Check that we maintain address spaces through template argument // deduction for a call. template<typename T> @@ -46,3 +60,16 @@ void test_accept_any_pointer(int_1_ptr ip1, int_2_ptr ip2) { accept_any_pointer(array); // expected-note{{in instantiation of}} } +template<typename T> struct identity {}; + +template<typename T> +identity<T> accept_arg_in_address_space_1(__attribute__((address_space(1))) T &ir1); + +template<typename T> +identity<T> accept_any_arg(T &ir1); + +void test_arg_in_address_space_1() { + static int __attribute__((address_space(1))) int_1; + identity<int> ii = accept_arg_in_address_space_1(int_1); + identity<int __attribute__((address_space(1)))> ii2 = accept_any_arg(int_1); +} |