| 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 | |
| 3 | // Test only flexible array member functionality specific to C++. |
| 4 | |
| 5 | union VariableSizeUnion { |
| 6 | int s; |
| 7 | char c[]; |
| 8 | }; |
| 9 | |
| 10 | @interface LastUnionIvar { |
| 11 | VariableSizeUnion flexible; |
| 12 | } |
| 13 | @end |
| 14 | |
| 15 | @interface NotLastUnionIvar { |
| 16 | VariableSizeUnion flexible; // expected-error {{field 'flexible' with variable sized type 'VariableSizeUnion' is not at the end of class}} |
| 17 | int last; // expected-note {{next instance variable declaration is here}} |
| 18 | } |
| 19 | @end |
| 20 | |
| 21 | |
| 22 | class VariableSizeClass { |
| 23 | public: |
| 24 | int s; |
| 25 | char c[]; |
| 26 | }; |
| 27 | |
| 28 | @interface LastClassIvar { |
| 29 | VariableSizeClass flexible; |
| 30 | } |
| 31 | @end |
| 32 | |
| 33 | @interface NotLastClassIvar { |
| 34 | VariableSizeClass flexible; // expected-error {{field 'flexible' with variable sized type 'VariableSizeClass' is not at the end of class}} |
| 35 | int last; // expected-note {{next instance variable declaration is here}} |
| 36 | } |
| 37 | @end |
| 38 | |