Anders Carlsson | e8820a8 | 2009-12-17 04:57:25 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s |
Anders Carlsson | 0a4f186 | 2009-12-17 04:41:05 +0000 | [diff] [blame] | 2 | #include <typeinfo> |
| 3 | |
| 4 | class __pbase_type_info : public std::type_info { |
| 5 | public: |
| 6 | unsigned int __flags; |
| 7 | const std::type_info *__pointee; |
| 8 | |
| 9 | enum __masks { |
| 10 | __const_mask = 0x1, |
| 11 | __volatile_mask = 0x2, |
| 12 | __restrict_mask = 0x4, |
| 13 | __incomplete_mask = 0x8, |
| 14 | __incomplete_class_mask = 0x10 |
| 15 | }; |
| 16 | }; |
| 17 | |
| 18 | template<typename T> const T& to(const std::type_info &info) { |
| 19 | return static_cast<const T&>(info); |
| 20 | } |
| 21 | struct Incomplete; |
| 22 | |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame^] | 23 | #define CHECK(x) if ((x)) return __LINE__; |
| 24 | |
Anders Carlsson | 0a4f186 | 2009-12-17 04:41:05 +0000 | [diff] [blame] | 25 | // CHECK: define i32 @_Z1fv() |
| 26 | int f() { |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame^] | 27 | // Pointers to incomplete classes. |
| 28 | CHECK(to<__pbase_type_info>(typeid(Incomplete *)).__flags != __pbase_type_info::__incomplete_mask); |
| 29 | CHECK(to<__pbase_type_info>(typeid(Incomplete **)).__flags != __pbase_type_info::__incomplete_mask); |
| 30 | CHECK(to<__pbase_type_info>(typeid(Incomplete ***)).__flags != __pbase_type_info::__incomplete_mask); |
| 31 | |
| 32 | // Member pointers. |
| 33 | CHECK(to<__pbase_type_info>(typeid(int Incomplete::*)).__flags != __pbase_type_info::__incomplete_class_mask); |
| 34 | |
Anders Carlsson | 0a4f186 | 2009-12-17 04:41:05 +0000 | [diff] [blame] | 35 | // Success! |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame^] | 36 | // CHECK: ret i32 0 |
Anders Carlsson | 0a4f186 | 2009-12-17 04:41:05 +0000 | [diff] [blame] | 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | #ifdef HARNESS |
| 41 | extern "C" void printf(const char *, ...); |
| 42 | |
| 43 | int main() { |
| 44 | int result = f(); |
| 45 | |
| 46 | if (result == 0) |
| 47 | printf("success!\n"); |
| 48 | else |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame^] | 49 | printf("test on line %d failed!\n", result); |
Anders Carlsson | 0a4f186 | 2009-12-17 04:41:05 +0000 | [diff] [blame] | 50 | |
| 51 | return result; |
| 52 | } |
| 53 | #endif |
| 54 | |
| 55 | |