xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/method-bad-param.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface foo
4*f4a2713aSLionel Sambuc@end
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc@implementation foo
7*f4a2713aSLionel Sambuc@end
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc@interface bar
10*f4a2713aSLionel Sambuc-(void) my_method:(foo) my_param; // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
11*f4a2713aSLionel Sambuc- (foo)cccccc:(long)ddddd;  // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
12*f4a2713aSLionel Sambuc@end
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc@implementation bar
15*f4a2713aSLionel Sambuc-(void) my_method:(foo) my_param  // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
16*f4a2713aSLionel Sambuc{
17*f4a2713aSLionel Sambuc}
18*f4a2713aSLionel Sambuc- (foo)cccccc:(long)ddddd // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
19*f4a2713aSLionel Sambuc{
20*f4a2713aSLionel Sambuc}
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambucvoid somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
24*f4a2713aSLionel Sambucfoo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc// rdar://6780761
27*f4a2713aSLionel Sambucvoid f0(foo *a0) {
28*f4a2713aSLionel Sambuc  extern void g0(int x, ...);
29*f4a2713aSLionel Sambuc  g0(1, *(foo*)a0);  // expected-error {{cannot pass object with interface type 'foo' by value through variadic function}}
30*f4a2713aSLionel Sambuc}
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc// rdar://8421082
33*f4a2713aSLionel Sambucenum bogus; // expected-note {{forward declaration of 'enum bogus'}}
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc@interface fee  {
36*f4a2713aSLionel Sambuc}
37*f4a2713aSLionel Sambuc- (void)crashMe:(enum bogus)p;
38*f4a2713aSLionel Sambuc@end
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc@implementation fee
41*f4a2713aSLionel Sambuc- (void)crashMe:(enum bogus)p { // expected-error {{variable has incomplete type 'enum bogus'}}
42*f4a2713aSLionel Sambuc}
43*f4a2713aSLionel Sambuc@end
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc@interface arrayfun
46*f4a2713aSLionel Sambuc- (int[6])arrayRet; // expected-error {{function cannot return array type 'int [6]'}}
47*f4a2713aSLionel Sambuc- (int())funcRet; // expected-error {{function cannot return function type 'int ()'}}
48*f4a2713aSLionel Sambuc@end
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel Sambuc@interface qux
51*f4a2713aSLionel Sambuc- (void) my_method: (int)arg; // expected-note {{method 'my_method:' declared here}}
52*f4a2713aSLionel Sambuc@end
53*f4a2713aSLionel Sambuc
54*f4a2713aSLionel Sambuc// FIXME: The diagnostic and recovery here could probably be improved.
55*f4a2713aSLionel Sambuc@implementation qux // expected-warning {{method definition for 'my_method:' not found}}
56*f4a2713aSLionel Sambuc- (void) my_method: (int) { // expected-error {{expected identifier}}
57*f4a2713aSLionel Sambuc}
58*f4a2713aSLionel Sambuc@end
59