File: method-bad-param.m

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (64 lines) | stat: -rw-r--r-- 2,199 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s

@interface foo
@end

@implementation foo
@end

@interface bar
-(void) my_method:(foo) my_param; // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
- (foo)cccccc:(long)ddddd;  // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
@end

@implementation bar
-(void) my_method:(foo) my_param  // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
{
}
- (foo)cccccc:(long)ddddd // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
{
}
@end

// Ensure that this function is properly marked as a failure.
void func_with_bad_call(bar* b, foo* f) {
  [b cccccc:5]; // expected-warning {{instance method '-cccccc:' not found}}
                // expected-note@-17 {{receiver is instance of class declared here}}
}

void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
foo somefunc2(void) {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}

// rdar://6780761
void f0(foo *a0) {
  extern void g0(int x, ...);
  g0(1, *(foo*)a0);  // expected-error {{cannot pass object with interface type 'foo' by value through variadic function}}
}

// rdar://8421082
enum bogus; // expected-note {{forward declaration of 'enum bogus'}}

@interface fee  {
}
- (void)crashMe:(enum bogus)p;
@end

@implementation fee
- (void)crashMe:(enum bogus)p { // expected-error {{variable has incomplete type 'enum bogus'}}
}
@end

@interface arrayfun
- (int[6])arrayRet; // expected-error {{function cannot return array type 'int[6]'}}
- (int(void))funcRet; // expected-error {{function cannot return function type 'int (void)'}}
@end

@interface qux
- (void) my_method: (int)arg; // expected-note {{method 'my_method:' declared here}}
@end

// FIXME: The diagnostic and recovery here could probably be improved.
@implementation qux // expected-warning {{method definition for 'my_method:' not found}}
- (void) my_method: (int) { // expected-error {{expected identifier}}
}
@end