Chris Lattner | ca79092 | 2009-04-21 19:55:16 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple x86_64-apple-darwin9 -verify -fsyntax-only %s |
Daniel Dunbar | ff89666 | 2009-04-21 15:48:54 +0000 | [diff] [blame] | 2 | |
| 3 | @class I0; |
Chris Lattner | ca79092 | 2009-04-21 19:55:16 +0000 | [diff] [blame] | 4 | |
| 5 | // rdar://6811884 |
Chris Lattner | 1efaa95 | 2009-04-24 00:30:45 +0000 | [diff] [blame] | 6 | int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}} |
| 7 | |
| 8 | // rdar://6821047 |
| 9 | void *g3(I0 *P) { |
| 10 | return &P[4]; // expected-error{{subscript of pointer to incomplete type 'I0'}} |
| 11 | } |
| 12 | |
| 13 | |
Daniel Dunbar | ff89666 | 2009-04-21 15:48:54 +0000 | [diff] [blame] | 14 | |
| 15 | @interface I0 { |
Chris Lattner | 1efaa95 | 2009-04-24 00:30:45 +0000 | [diff] [blame] | 16 | @public |
Daniel Dunbar | ff89666 | 2009-04-21 15:48:54 +0000 | [diff] [blame] | 17 | char x[4]; |
| 18 | } |
| 19 | |
| 20 | @property int p0; |
| 21 | @end |
| 22 | |
| 23 | // size == 4 |
Chris Lattner | 1efaa95 | 2009-04-24 00:30:45 +0000 | [diff] [blame] | 24 | int g1[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}} |
Chris Lattner | ca79092 | 2009-04-21 19:55:16 +0000 | [diff] [blame] | 25 | == 4 ? 1 : -1]; |
Daniel Dunbar | ff89666 | 2009-04-21 15:48:54 +0000 | [diff] [blame] | 26 | |
| 27 | @implementation I0 |
| 28 | @synthesize p0 = _p0; |
| 29 | @end |
| 30 | |
| 31 | // size == 4 (we do not include extended properties in the |
| 32 | // sizeof). |
Chris Lattner | 1efaa95 | 2009-04-24 00:30:45 +0000 | [diff] [blame] | 33 | int g2[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}} |
Chris Lattner | ca79092 | 2009-04-21 19:55:16 +0000 | [diff] [blame] | 34 | == 4 ? 1 : -1]; |
Daniel Dunbar | ff89666 | 2009-04-21 15:48:54 +0000 | [diff] [blame] | 35 | |
| 36 | @interface I1 |
| 37 | @property int p0; |
| 38 | @end |
| 39 | |
| 40 | @implementation I1 |
| 41 | @synthesize p0 = _p0; |
| 42 | @end |
| 43 | |
Fariborz Jahanian | 0468fb9 | 2009-04-21 20:28:41 +0000 | [diff] [blame] | 44 | typedef struct { @defs(I1) } I1_defs; // expected-error {{invalid application of @defs in non-fragile ABI}} |
| 45 | |
Daniel Dunbar | ff89666 | 2009-04-21 15:48:54 +0000 | [diff] [blame] | 46 | // FIXME: This is currently broken due to the way the record layout we |
| 47 | // create is tied to whether we have seen synthesized properties. Ugh. |
| 48 | // int g3[ sizeof(I1) == 0 ? 1 : -1]; |
Chris Lattner | 1efaa95 | 2009-04-24 00:30:45 +0000 | [diff] [blame] | 49 | |
| 50 | // rdar://6821047 |
| 51 | int bar(I0 *P) { |
| 52 | return P[4].x[2]; // expected-error {{subscript requires size of interface 'I0', which is not constant in non-fragile ABI}} |
| 53 | } |
| 54 | |
Fariborz Jahanian | ced1e28 | 2009-04-24 17:34:33 +0000 | [diff] [blame^] | 55 | |
| 56 | @interface I @end |
| 57 | |
| 58 | @interface XCAttributeRunDirectNode |
| 59 | { |
| 60 | @public |
| 61 | unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{invalid application of 'sizeof' to interface 'I' in non-fragile ABI}} |
| 62 | int i; |
| 63 | } |
| 64 | @end |
| 65 | |
| 66 | @implementation XCAttributeRunDirectNode |
| 67 | |
| 68 | - (unsigned long)gatherStats:(id )stats |
| 69 | { |
| 70 | return attributeRuns[i]; |
| 71 | } |
| 72 | @end |
| 73 | |