brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 34a0895 Raw
115 lines · cpp
1// To avoid linking MSVC specific libs, we don't test virtual/override methods2// that needs vftable support in this file.3 4// Enum.5enum Enum { RED, GREEN, BLUE };6Enum EnumVar;7 8// Union.9union 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};16Union UnionVar;17 18// Struct.19struct Struct;20typedef Struct StructTypedef;21 22struct 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};30struct Struct StructVar;31 32struct _List; // Forward declaration.33struct 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};43struct Complex c;44 45struct _List { // Test doubly linked list.46  struct _List *current;47  struct _List *previous;48  struct _List *next;49};50struct _List ListVar;51 52typedef struct {53  int a;54} UnnamedStruct; // Test unnamed typedef-ed struct.55UnnamedStruct UnnanmedVar;56 57// Class.58namespace MemberTest {59class Base {60public:61  Base() {}62  ~Base() {}63 64public:65  int Get() { return 0; }66 67protected:68  int a;69};70class Friend {71public:72  int f() { return 3; }73};74class Class : public Base { // Test base class.75  friend Friend;76  static int m_static; // Test static member variable.77public: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 92public:93  int m_public;94  struct Struct m_struct;95 96private:97  Union m_union;98  int m_private;99 100protected:101  friend class Friend;102  int m_protected;103};104} // namespace MemberTest105 106int main() {107  MemberTest::Base B1;108  B1.Get();109  // Create instance of C1 so that it has debug info (due to constructor110  // homing).111  MemberTest::Class C1;112  MemberTest::Class::StaticMemberFunc(1, 10, 2);113  return 0;114}115