1 // RUN: %clang_cc1 -std=c++11 -fobjc-runtime-has-weak -fobjc-weak -fobjc-arc -fsyntax-only -verify %s
3 void __attribute__((trivial_abi)) foo(); // expected-warning {{'trivial_abi' attribute only applies to classes}}
5 struct [[clang::trivial_abi]] S0 {
9 struct __attribute__((trivial_abi)) S1 {
13 struct __attribute__((trivial_abi)) S2 { // expected-warning {{'trivial_abi' cannot be applied to 'S2'}} expected-note {{has a __weak field}}
17 struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}} expected-note {{is polymorphic}}
23 } __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}} expected-note {{is polymorphic}}
29 struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}} expected-note {{has a virtual base}}
32 struct __attribute__((trivial_abi)) S9 : public S4 {
39 struct __attribute__((trivial_abi)) S12 { // expected-warning {{'trivial_abi' cannot be applied to 'S12'}} expected-note {{has a __weak field}}
43 struct __attribute__((trivial_abi)) S13 { // expected-warning {{'trivial_abi' cannot be applied to 'S13'}} expected-note {{has a __weak field}}
47 struct __attribute__((trivial_abi)) S7 { // expected-warning {{'trivial_abi' cannot be applied to 'S7'}} expected-note {{has a field of a non-trivial class type}}
51 struct __attribute__((trivial_abi)) S11 { // expected-warning {{'trivial_abi' cannot be applied to 'S11'}} expected-note {{has a field of a non-trivial class type}}
55 struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' attribute takes no arguments}}
59 // Do not warn when 'trivial_abi' is used to annotate a template class.
61 struct __attribute__((trivial_abi)) S10 {
69 struct __attribute__((trivial_abi)) S10<id> { // expected-warning {{'trivial_abi' cannot be applied to 'S10<id>'}} expected-note {{has a __weak field}}
80 struct __attribute__((trivial_abi)) S15 : S14<T> {
86 struct __attribute__((trivial_abi)) S16 {
93 struct __attribute__((trivial_abi)) S17 { // expected-warning {{'trivial_abi' cannot be applied to 'S17'}} expected-note {{has a __weak field}}
99 struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{has a __weak field}}
105 namespace deletedCopyMoveConstructor {
106 struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
107 CopyMoveDeleted(const CopyMoveDeleted &) = delete;
108 CopyMoveDeleted(CopyMoveDeleted &&) = delete;
111 struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
115 struct __attribute__((trivial_abi)) CopyDeleted {
116 CopyDeleted(const CopyDeleted &) = delete;
117 CopyDeleted(CopyDeleted &&) = default;
120 struct __attribute__((trivial_abi)) MoveDeleted {
121 MoveDeleted(const MoveDeleted &) = default;
122 MoveDeleted(MoveDeleted &&) = delete;
125 struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
130 // This is fine since the move constructor isn't deleted.
131 struct __attribute__((trivial_abi)) S20 {
132 int &&a; // a member of rvalue reference type deletes the copy constructor.