StmtPrinter: factor out arg printing code to PrintCallArgs
[clang.git] / test / SemaObjCXX / objc-pointer-conv.mm
blob209dcfdfd70590ab1f7388e19e697d41682c8fe1
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 typedef const void * VoidStar;
5 typedef struct __CFDictionary * CFMDRef;
7 void RandomFunc(CFMDRef theDict, const void *key, const void *value);
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
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);
21 - (void)a:(id *)objects b:(id *)keys {
22     VoidStar dict;
23         id key;
24     RandomFunc((CFMDRef)dict, key, objects[3]);
26 @end
28 @interface I
29 - (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}}
30 @end
32 void Func (I* arg);  // expected-note {{candidate function not viable: no known conversion from 'const I *' to 'I *' for 1st argument}}
34 void foo(const I *p, I* sel) {
35   [sel Meth : p];       // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'const I *'}}
36   Func(p);              // expected-error {{no matching function for call to 'Func'}}
39 @interface DerivedFromI : I
40 @end
42 void accept_derived(DerivedFromI*);
44 void test_base_to_derived(I* i) {
45   accept_derived(i); // expected-warning{{incompatible pointer types passing 'I *' to parameter of type 'DerivedFromI *'}}
46   DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'I *' with an expression of type 'DerivedFromI *'}}
47   DerivedFromI *di2 = (DerivedFromI *)i;