blob: 335c240c171d11b636b26d5e9ac1b920be9ec544 [file] [log] [blame]
Fariborz Jahanianadcfab12009-12-16 23:13:33 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3typedef const void * VoidStar;
4
5typedef struct __CFDictionary * CFMDRef;
6
7void RandomFunc(CFMDRef theDict, const void *key, const void *value);
8
9@interface Foo
10- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context;
11- (void)a:(id *)objects b:(id *)keys;
12@end
13
14@implementation Foo
15- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context {
16 id item;
17 id obj;
18 func(item, obj, context);
19}
20
21- (void)a:(id *)objects b:(id *)keys {
22 VoidStar dict;
23 id key;
24 RandomFunc((CFMDRef)dict, key, objects[3]);
25}
26@end
Fariborz Jahanianee9ca692010-03-15 18:36:00 +000027
28@interface I
Douglas Gregora41a8c52010-04-22 00:20:18 +000029- (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}}
Fariborz Jahanianee9ca692010-03-15 18:36:00 +000030@end
31
Chris Lattnerd7e52b82010-09-05 00:43:21 +000032void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'const I *' to 'I *' for 1st argument}}
Fariborz Jahanianee9ca692010-03-15 18:36:00 +000033
34void foo(const I *p, I* sel) {
Chris Lattnerd7e52b82010-09-05 00:43:21 +000035 [sel Meth : p]; // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'const I *'}}
Fariborz Jahanianee9ca692010-03-15 18:36:00 +000036 Func(p); // expected-error {{no matching function for call to 'Func'}}
37}
38
Douglas Gregor85789812010-06-30 23:01:39 +000039@interface DerivedFromI : I
40@end
41
Douglas Gregor2f9d8742010-07-01 02:14:45 +000042void accept_derived(DerivedFromI*); // expected-note{{candidate function not viable: cannot convert from superclass 'I *' to subclass 'DerivedFromI *' for 1st argument}}
Douglas Gregor85789812010-06-30 23:01:39 +000043
44void test_base_to_derived(I* i) {
45 accept_derived(i); // expected-error{{no matching function for call to 'accept_derived'}}
46}