Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | template<typename T> |
| 3 | struct is_pointer { |
| 4 | static const bool value = false; |
| 5 | }; |
| 6 | |
| 7 | template<typename T> |
| 8 | struct is_pointer<T*> { |
| 9 | static const bool value = true; |
| 10 | }; |
| 11 | |
| 12 | template<typename T> |
| 13 | struct is_pointer<const T*> { |
| 14 | static const bool value = true; |
| 15 | }; |
| 16 | |
| 17 | int array0[is_pointer<int>::value? -1 : 1]; |
| 18 | int array1[is_pointer<int*>::value? 1 : -1]; |
| 19 | int array2[is_pointer<const int*>::value? 1 : -1]; // expected-error{{partial ordering}} \ |
| 20 | // expected-error{{negative}} |
Douglas Gregor | 0b9247f | 2009-06-04 00:03:07 +0000 | [diff] [blame] | 21 | |
Douglas Gregor | d560d50 | 2009-06-04 00:21:18 +0000 | [diff] [blame] | 22 | template<typename T> |
| 23 | struct is_lvalue_reference { |
| 24 | static const bool value = false; |
| 25 | }; |
| 26 | |
| 27 | template<typename T> |
| 28 | struct is_lvalue_reference<T&> { |
| 29 | static const bool value = true; |
| 30 | }; |
| 31 | |
| 32 | int lvalue_ref0[is_lvalue_reference<int>::value? -1 : 1]; |
| 33 | int lvalue_ref1[is_lvalue_reference<const int&>::value? 1 : -1]; |
| 34 | |
Douglas Gregor | 0b9247f | 2009-06-04 00:03:07 +0000 | [diff] [blame] | 35 | template<typename T, typename U> |
| 36 | struct is_same { |
| 37 | static const bool value = false; |
| 38 | }; |
| 39 | |
| 40 | template<typename T> |
| 41 | struct is_same<T, T> { |
| 42 | static const bool value = true; |
| 43 | }; |
| 44 | |
| 45 | typedef int INT; |
| 46 | typedef INT* int_ptr; |
| 47 | |
| 48 | int is_same0[is_same<int, int>::value? 1 : -1]; |
| 49 | int is_same1[is_same<int, INT>::value? 1 : -1]; |
| 50 | int is_same2[is_same<const int, int>::value? -1 : 1]; |
| 51 | int is_same3[is_same<int_ptr, int>::value? -1 : 1]; |
Anders Carlsson | 4d6fb50 | 2009-06-04 04:11:30 +0000 | [diff] [blame^] | 52 | |
| 53 | template<typename T> |
| 54 | struct is_incomplete_array { |
| 55 | static const bool value = false; |
| 56 | }; |
| 57 | |
| 58 | template<typename T> |
| 59 | struct is_incomplete_array<T[]> { |
| 60 | static const bool value = true; |
| 61 | }; |
| 62 | |
| 63 | int incomplete_array0[is_incomplete_array<int>::value ? -1 : 1]; |
| 64 | int incomplete_array1[is_incomplete_array<int[1]>::value ? -1 : 1]; |
| 65 | int incomplete_array2[is_incomplete_array<bool[]>::value ? 1 : -1]; |
| 66 | int incomplete_array3[is_incomplete_array<int[]>::value ? 1 : -1]; |
| 67 | |
| 68 | template<typename T> |
| 69 | struct is_array_with_4_elements { |
| 70 | static const bool value = false; |
| 71 | }; |
| 72 | |
| 73 | template<typename T> |
| 74 | struct is_array_with_4_elements<T[4]> { |
| 75 | static const bool value = true; |
| 76 | }; |
| 77 | |
| 78 | int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1]; |
| 79 | int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1]; |
| 80 | int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1]; |
| 81 | int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1]; |