Anders Carlsson | 0a4f186 | 2009-12-17 04:41:05 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s |
| 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 | |
| 23 | // CHECK: define i32 @_Z1fv() |
| 24 | int f() { |
| 25 | if (to<__pbase_type_info>(typeid(Incomplete *)).__flags != __pbase_type_info::__incomplete_mask) |
| 26 | return 1; |
| 27 | |
| 28 | // Success! |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | #ifdef HARNESS |
| 33 | extern "C" void printf(const char *, ...); |
| 34 | |
| 35 | int main() { |
| 36 | int result = f(); |
| 37 | |
| 38 | if (result == 0) |
| 39 | printf("success!\n"); |
| 40 | else |
| 41 | printf("test %d failed!\n", result); |
| 42 | |
| 43 | return result; |
| 44 | } |
| 45 | #endif |
| 46 | |
| 47 | |