1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuctypedef const void * VoidStar; 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuctypedef struct __CFDictionary * CFMDRef; 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambucvoid RandomFunc(CFMDRef theDict, const void *key, const void *value); 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc@interface Foo 10*f4a2713aSLionel Sambuc- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context; 11*f4a2713aSLionel Sambuc- (void)a:(id *)objects b:(id *)keys; 12*f4a2713aSLionel Sambuc@end 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc@implementation Foo 15*f4a2713aSLionel Sambuc- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context { 16*f4a2713aSLionel Sambuc id item; 17*f4a2713aSLionel Sambuc id obj; 18*f4a2713aSLionel Sambuc func(item, obj, context); 19*f4a2713aSLionel Sambuc} 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc- (void)a:(id *)objects b:(id *)keys { 22*f4a2713aSLionel Sambuc VoidStar dict; 23*f4a2713aSLionel Sambuc id key; 24*f4a2713aSLionel Sambuc RandomFunc((CFMDRef)dict, key, objects[3]); 25*f4a2713aSLionel Sambuc} 26*f4a2713aSLionel Sambuc@end 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc@interface I 29*f4a2713aSLionel Sambuc- (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}} 30*f4a2713aSLionel Sambuc@end 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambucvoid Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'const I *' to 'I *' for 1st argument}} 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambucvoid foo(const I *p, I* sel) { 35*f4a2713aSLionel Sambuc [sel Meth : p]; // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'const I *'}} 36*f4a2713aSLionel Sambuc Func(p); // expected-error {{no matching function for call to 'Func'}} 37*f4a2713aSLionel Sambuc} 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc@interface DerivedFromI : I 40*f4a2713aSLionel Sambuc@end 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambucvoid accept_derived(DerivedFromI*); 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambucvoid test_base_to_derived(I* i) { 45*f4a2713aSLionel Sambuc accept_derived(i); // expected-warning{{incompatible pointer types passing 'I *' to parameter of type 'DerivedFromI *'}} 46*f4a2713aSLionel Sambuc DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'DerivedFromI *' with an expression of type 'I *'}} 47*f4a2713aSLionel Sambuc DerivedFromI *di2 = (DerivedFromI *)i; 48*f4a2713aSLionel Sambuc} 49