blob: ad67a34edb00c3ebedbac1e197adc36aa1931dfa [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
Fariborz Jahanian9bae5e72009-01-17 21:57:49 +00002
3@interface foo
4@end
5
6@implementation foo
7@end
8
9@interface bar
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000010-(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 Jahanian9bae5e72009-01-17 21:57:49 +000012@end
13
14@implementation bar
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000015-(void) my_method:(foo) my_param // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
Steve Naroffccef3712009-02-20 22:59:16 +000016{
17}
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000018- (foo)cccccc:(long)ddddd // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
Fariborz Jahanian9bae5e72009-01-17 21:57:49 +000019{
20}
21@end
22
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000023void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
24foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
Chris Lattner312531a2009-04-12 08:11:20 +000025
26// rdar://6780761
27void f0(foo *a0) {
28 extern void g0(int x, ...);
Jordan Roseddcfbc92012-07-19 18:10:23 +000029 g0(1, *(foo*)a0); // expected-error {{cannot pass object with interface type 'foo' by value through variadic function}}
Chris Lattner312531a2009-04-12 08:11:20 +000030}
Fariborz Jahanian23c01042010-09-17 22:07:07 +000031
32// rdar://8421082
33enum 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 Friedmanddb5a392013-06-14 21:14:10 +000045@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 Kleckner8c0501c2013-06-24 14:38:26 +000049
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