1 #define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor"))) 2 3 struct MOZ_TRIVIAL_CTOR_DTOR EmptyClass{}; 4 5 template <class T> 6 struct MOZ_TRIVIAL_CTOR_DTOR TemplateEmptyClass{}; 7 8 struct MOZ_TRIVIAL_CTOR_DTOR NonEmptyClass { 9 void *m; 10 }; 11 12 template <class T> 13 struct MOZ_TRIVIAL_CTOR_DTOR TemplateNonEmptyClass { 14 T* m; 15 }; 16 17 struct MOZ_TRIVIAL_CTOR_DTOR BadUserDefinedCtor { // expected-error {{class 'BadUserDefinedCtor' must have trivial constructors and destructors}} BadUserDefinedCtorBadUserDefinedCtor18 BadUserDefinedCtor() {} 19 }; 20 21 struct MOZ_TRIVIAL_CTOR_DTOR BadUserDefinedDtor { // expected-error {{class 'BadUserDefinedDtor' must have trivial constructors and destructors}} ~BadUserDefinedDtorBadUserDefinedDtor22 ~BadUserDefinedDtor() {} 23 }; 24 25 struct MOZ_TRIVIAL_CTOR_DTOR BadVirtualDtor { // expected-error {{class 'BadVirtualDtor' must have trivial constructors and destructors}} ~BadVirtualDtorBadVirtualDtor26 virtual ~BadVirtualDtor() {} 27 }; 28 29 struct MOZ_TRIVIAL_CTOR_DTOR OkVirtualMember { 30 virtual void f(); 31 }; 32 33 void foo(); 34 struct MOZ_TRIVIAL_CTOR_DTOR BadNonEmptyCtorDtor { // expected-error {{class 'BadNonEmptyCtorDtor' must have trivial constructors and destructors}} BadNonEmptyCtorDtorBadNonEmptyCtorDtor35 BadNonEmptyCtorDtor() { foo(); } ~BadNonEmptyCtorDtorBadNonEmptyCtorDtor36 ~BadNonEmptyCtorDtor() { foo(); } 37 }; 38 39 struct NonTrivialCtor { NonTrivialCtorNonTrivialCtor40 NonTrivialCtor() { foo(); } 41 }; 42 43 struct NonTrivialDtor { ~NonTrivialDtorNonTrivialDtor44 ~NonTrivialDtor() { foo(); } 45 }; 46 47 struct VirtualMember { 48 virtual void f(); 49 }; 50 51 struct MOZ_TRIVIAL_CTOR_DTOR BadNonTrivialCtorInBase : NonTrivialCtor { // expected-error {{class 'BadNonTrivialCtorInBase' must have trivial constructors and destructors}} 52 }; 53 54 struct MOZ_TRIVIAL_CTOR_DTOR BadNonTrivialDtorInBase : NonTrivialDtor { // expected-error {{class 'BadNonTrivialDtorInBase' must have trivial constructors and destructors}} 55 }; 56 57 struct MOZ_TRIVIAL_CTOR_DTOR BadNonTrivialCtorInMember { // expected-error {{class 'BadNonTrivialCtorInMember' must have trivial constructors and destructors}} 58 NonTrivialCtor m; 59 }; 60 61 struct MOZ_TRIVIAL_CTOR_DTOR BadNonTrivialDtorInMember { // expected-error {{class 'BadNonTrivialDtorInMember' must have trivial constructors and destructors}} 62 NonTrivialDtor m; 63 }; 64 65 struct MOZ_TRIVIAL_CTOR_DTOR OkVirtualMemberInMember { 66 VirtualMember m; 67 }; 68 69 struct MOZ_TRIVIAL_CTOR_DTOR OkConstExprConstructor { OkConstExprConstructorOkConstExprConstructor70 constexpr OkConstExprConstructor() {} 71 }; 72 73 struct MOZ_TRIVIAL_CTOR_DTOR OkConstExprConstructorInMember { 74 OkConstExprConstructor m; 75 }; 76 77 // XXX: This error is unfortunate, but is unlikely to come up in real code. 78 // In this situation, it should be possible to define a constexpr constructor 79 // which explicitly initializes the members. 80 struct MOZ_TRIVIAL_CTOR_DTOR BadUnfortunateError { // expected-error {{class 'BadUnfortunateError' must have trivial constructors and destructors}} 81 OkConstExprConstructor m; 82 void *n; 83 }; 84