Fariborz Jahanian | 99130e5 | 2010-12-22 19:46:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | // rdar://8155806 |
| 3 | |
| 4 | @interface Subclass |
| 5 | { |
| 6 | int setterOnly; |
| 7 | } |
| 8 | - (void) setSetterOnly : (int) arg; |
| 9 | @end |
| 10 | |
| 11 | int func (int arg, Subclass *x) { |
Eli Friedman | a70779f | 2012-11-29 03:13:49 +0000 | [diff] [blame] | 12 | if (x.setterOnly) { // expected-error {{no getter method for read from property}} |
Fariborz Jahanian | 99130e5 | 2010-12-22 19:46:35 +0000 | [diff] [blame] | 13 | x.setterOnly = 1; |
| 14 | } |
Eli Friedman | a70779f | 2012-11-29 03:13:49 +0000 | [diff] [blame] | 15 | func(x.setterOnly + 1, x); // expected-error {{no getter method for read from property}} |
| 16 | int i = x.setterOnly + 1; // expected-error {{no getter method for read from property}} |
| 17 | return x.setterOnly + 1; // expected-error {{no getter method for read from property}} |
Fariborz Jahanian | 99130e5 | 2010-12-22 19:46:35 +0000 | [diff] [blame] | 18 | } |
| 19 | |
Eli Friedman | a70779f | 2012-11-29 03:13:49 +0000 | [diff] [blame] | 20 | // <rdar://problem/12765391> |
| 21 | |
| 22 | @interface TestClass |
| 23 | + (void) setSetterOnly : (int) arg; |
| 24 | @end |
| 25 | |
| 26 | int func2 (int arg) { |
| 27 | if (TestClass.setterOnly) { // expected-error {{no getter method for read from property}} |
| 28 | TestClass.setterOnly = 1; |
| 29 | } |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 30 | func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}} \ |
| 31 | // expected-error {{use of undeclared identifier 'x'}} |
Eli Friedman | a70779f | 2012-11-29 03:13:49 +0000 | [diff] [blame] | 32 | int i = TestClass.setterOnly + 1; // expected-error {{no getter method for read from property}} |
| 33 | return TestClass.setterOnly + 1; // expected-error {{no getter method for read from property}} |
| 34 | } |
| 35 | |
| 36 | @interface Sub : Subclass |
| 37 | - (int) func3; |
| 38 | @end |
| 39 | @implementation Sub |
| 40 | - (int) func3 { |
| 41 | return super.setterOnly; // expected-error {{no getter method for read from property}} |
| 42 | } |
| 43 | @end |