blob: 3e97592ada1ad851cb7b24b5132132d8100a2e55 [file] [log] [blame]
Anders Carlssone8820a82009-12-17 04:57:25 +00001// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
Anders Carlsson0a4f1862009-12-17 04:41:05 +00002#include <typeinfo>
3
4class __pbase_type_info : public std::type_info {
5public:
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
18template<typename T> const T& to(const std::type_info &info) {
19return static_cast<const T&>(info);
20}
21struct Incomplete;
22
Anders Carlsson8d145152009-12-20 22:30:54 +000023#define CHECK(x) if ((x)) return __LINE__;
24
Anders Carlsson0a4f1862009-12-17 04:41:05 +000025// CHECK: define i32 @_Z1fv()
26int f() {
Anders Carlsson8d145152009-12-20 22:30:54 +000027 // 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 Carlsson0a4f1862009-12-17 04:41:05 +000035 // Success!
Anders Carlsson8d145152009-12-20 22:30:54 +000036 // CHECK: ret i32 0
Anders Carlsson0a4f1862009-12-17 04:41:05 +000037 return 0;
38}
39
40#ifdef HARNESS
41extern "C" void printf(const char *, ...);
42
43int main() {
44 int result = f();
45
46 if (result == 0)
47 printf("success!\n");
48 else
Anders Carlsson8d145152009-12-20 22:30:54 +000049 printf("test on line %d failed!\n", result);
Anders Carlsson0a4f1862009-12-17 04:41:05 +000050
51 return result;
52}
53#endif
54
55