Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
Fariborz Jahanian | 9bae5e7 | 2009-01-17 21:57:49 +0000 | [diff] [blame] | 2 | |
| 3 | @interface foo |
| 4 | @end |
| 5 | |
| 6 | @implementation foo |
| 7 | @end |
| 8 | |
| 9 | @interface bar |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 10 | -(void) my_method:(foo) my_param; // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}} |
| 11 | - (foo)cccccc:(long)ddddd; // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}} |
Fariborz Jahanian | 9bae5e7 | 2009-01-17 21:57:49 +0000 | [diff] [blame] | 12 | @end |
| 13 | |
| 14 | @implementation bar |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 15 | -(void) my_method:(foo) my_param // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}} |
Steve Naroff | ccef371 | 2009-02-20 22:59:16 +0000 | [diff] [blame] | 16 | { |
| 17 | } |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 18 | - (foo)cccccc:(long)ddddd // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}} |
Fariborz Jahanian | 9bae5e7 | 2009-01-17 21:57:49 +0000 | [diff] [blame] | 19 | { |
| 20 | } |
| 21 | @end |
| 22 | |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 23 | void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}} |
| 24 | foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}} |
Chris Lattner | 312531a | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 25 | |
| 26 | // rdar://6780761 |
| 27 | void f0(foo *a0) { |
| 28 | extern void g0(int x, ...); |
Jordan Rose | ddcfbc9 | 2012-07-19 18:10:23 +0000 | [diff] [blame] | 29 | g0(1, *(foo*)a0); // expected-error {{cannot pass object with interface type 'foo' by value through variadic function}} |
Chris Lattner | 312531a | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 30 | } |
Fariborz Jahanian | 23c0104 | 2010-09-17 22:07:07 +0000 | [diff] [blame] | 31 | |
| 32 | // rdar://8421082 |
| 33 | enum bogus; // expected-note {{forward declaration of 'enum bogus'}} |
| 34 | |
| 35 | @interface fee { |
| 36 | } |
| 37 | - (void)crashMe:(enum bogus)p; |
| 38 | @end |
| 39 | |
| 40 | @implementation fee |
| 41 | - (void)crashMe:(enum bogus)p { // expected-error {{variable has incomplete type 'enum bogus'}} |
| 42 | } |
| 43 | @end |
| 44 | |
Eli Friedman | ddb5a39 | 2013-06-14 21:14:10 +0000 | [diff] [blame] | 45 | @interface arrayfun |
| 46 | - (int[6])arrayRet; // expected-error {{function cannot return array type 'int [6]'}} |
| 47 | - (int())funcRet; // expected-error {{function cannot return function type 'int ()'}} |
| 48 | @end |
Reid Kleckner | 8c0501c | 2013-06-24 14:38:26 +0000 | [diff] [blame] | 49 | |
| 50 | @interface qux |
| 51 | - (void) my_method: (int)arg; // expected-note {{method 'my_method:' declared here}} |
| 52 | @end |
| 53 | |
| 54 | // FIXME: The diagnostic and recovery here could probably be improved. |
| 55 | @implementation qux // expected-warning {{method definition for 'my_method:' not found}} |
| 56 | - (void) my_method: (int) { // expected-error {{expected identifier}} |
| 57 | } |
| 58 | @end |