1 | // To avoid linking MSVC specific libs, we don't test virtual/override methods |
2 | // that needs vftable support in this file. |
3 | |
4 | // Enum. |
5 | enum Enum { RED, GREEN, BLUE }; |
6 | Enum EnumVar; |
7 | |
8 | // Union. |
9 | union Union { |
10 | short Row; |
11 | unsigned short Col; |
12 | int Line : 16; // Test named bitfield. |
13 | short : 8; // Unnamed bitfield symbol won't be generated in PDB. |
14 | long Table; |
15 | }; |
16 | Union UnionVar; |
17 | |
18 | // Struct. |
19 | struct Struct; |
20 | typedef Struct StructTypedef; |
21 | |
22 | struct Struct { |
23 | bool A; |
24 | unsigned char UCharVar; |
25 | unsigned int UIntVar; |
26 | long long LongLongVar; |
27 | Enum EnumVar; // Test struct has UDT member. |
28 | int array[10]; |
29 | }; |
30 | struct Struct StructVar; |
31 | |
32 | struct _List; // Forward declaration. |
33 | struct Complex { |
34 | struct _List *array[90]; |
35 | struct { // Test unnamed struct. MSVC treats it as `int x` |
36 | int x; |
37 | }; |
38 | union { // Test unnamed union. MSVC treats it as `int a; float b;` |
39 | int a; |
40 | float b; |
41 | }; |
42 | }; |
43 | struct Complex c; |
44 | |
45 | struct _List { // Test doubly linked list. |
46 | struct _List *current; |
47 | struct _List *previous; |
48 | struct _List *next; |
49 | }; |
50 | struct _List ListVar; |
51 | |
52 | typedef struct { |
53 | int a; |
54 | } UnnamedStruct; // Test unnamed typedef-ed struct. |
55 | UnnamedStruct UnnanmedVar; |
56 | |
57 | // Class. |
58 | namespace MemberTest { |
59 | class Base { |
60 | public: |
61 | Base() {} |
62 | ~Base() {} |
63 | |
64 | public: |
65 | int Get() { return 0; } |
66 | |
67 | protected: |
68 | int a; |
69 | }; |
70 | class Friend { |
71 | public: |
72 | int f() { return 3; } |
73 | }; |
74 | class Class : public Base { // Test base class. |
75 | friend Friend; |
76 | static int m_static; // Test static member variable. |
77 | public: |
78 | Class() : m_public(), m_private(), m_protected() {} |
79 | explicit Class(int a) { m_public = a; } // Test first reference of m_public. |
80 | ~Class() {} |
81 | |
82 | static int StaticMemberFunc(int a, ...) { |
83 | return 1; |
84 | } // Test static member function. |
85 | int Get() { return 1; } |
86 | int f(Friend c) { return c.f(); } |
87 | inline bool operator==(const Class &rhs) const // Test operator. |
88 | { |
89 | return (m_public == rhs.m_public); |
90 | } |
91 | |
92 | public: |
93 | int m_public; |
94 | struct Struct m_struct; |
95 | |
96 | private: |
97 | Union m_union; |
98 | int m_private; |
99 | |
100 | protected: |
101 | friend class Friend; |
102 | int m_protected; |
103 | }; |
104 | } // namespace MemberTest |
105 | |
106 | int main() { |
107 | MemberTest::Base B1; |
108 | B1.Get(); |
109 | // Create instance of C1 so that it has debug info (due to constructor |
110 | // homing). |
111 | MemberTest::Class C1; |
112 | MemberTest::Class::StaticMemberFunc(a: 1, 10, 2); |
113 | return 0; |
114 | } |
115 | |