1 /* -*- C++ -*- */ 2 namespace DebugCXX { 3 // Records. 4 struct Struct { 5 int i; 6 static int static_member; 7 }; 8 9 // Enums. 10 enum Enum { 11 Enumerator 12 }; 13 enum { 14 e1 = '1' 15 }; 16 enum { 17 e2 = '2' 18 }; 19 20 // Templates (instantiations). 21 template<typename T> struct traits {}; 22 template<typename T, 23 typename Traits = traits<T> 24 > class Template { 25 T member; 26 }; 27 // Explicit template instantiation. 28 extern template class Template<int>; 29 30 extern template struct traits<float>; 31 typedef class Template<float> FloatInstantiation; 32 33 inline void fn() { 34 Template<long> invisible; 35 } 36 37 // Non-template inside a template. 38 template <class> struct Outer { 39 Outer(); 40 struct Inner { 41 Inner(Outer) {} 42 }; 43 }; 44 template <class T> Outer<T>::Outer() { 45 Inner a(*this); 46 }; 47 48 // Partial template specialization. 49 template <typename...> class A; 50 template <typename T> class A<T> {}; 51 typedef A<void> B; 52 // Anchored by a function parameter. 53 void foo(B) {} 54 } 55 56 // Virtual class with a forward declaration. 57 class FwdVirtual; 58 class FwdVirtual { 59 virtual ~FwdVirtual() {} 60 }; 61 62 struct PureForwardDecl; 63 64 typedef union { int i; } TypedefUnion; 65 typedef enum { e0 = 0 } TypedefEnum; 66 typedef struct { int i; } TypedefStruct; 67 68 union { int i; } GlobalUnion; 69 struct { int i; } GlobalStruct; 70 enum { e5 = 5 } GlobalEnum; 71 72 namespace { 73 namespace { 74 struct InAnonymousNamespace { int i; }; 75 } 76 } 77 78 class Base; 79 class A { 80 virtual Base *getParent() const; 81 }; 82 class Base {}; 83 class Derived : Base { 84 class B : A { 85 Derived *getParent() const override; 86 }; 87 }; 88 89 template <class T> 90 class Template1 { 91 T t; 92 }; 93 typedef Template1<void *> TypedefTemplate; 94 extern template class Template1<int>; 95 96 template <class T> class FwdDeclTemplate; 97 typedef FwdDeclTemplate<int> TypedefFwdDeclTemplate; 98 99 // Member classes of class template specializations. 100 template <typename T> struct Specialized {}; 101 102 template <> struct Specialized<int> { 103 struct Member; 104 }; 105 106 template <class T> struct FwdDeclTemplateMember { struct Member; }; 107 typedef FwdDeclTemplateMember<int>::Member TypedefFwdDeclTemplateMember; 108