1*acfbe9e1SPatrick Beard// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 201cbe441SFariborz Jahanian 301cbe441SFariborz Jahaniantypedef const void * VoidStar; 401cbe441SFariborz Jahanian 501cbe441SFariborz Jahaniantypedef struct __CFDictionary * CFMDRef; 601cbe441SFariborz Jahanian 701cbe441SFariborz Jahanianvoid RandomFunc(CFMDRef theDict, const void *key, const void *value); 801cbe441SFariborz Jahanian 901cbe441SFariborz Jahanian@interface Foo 1001cbe441SFariborz Jahanian- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context; 1101cbe441SFariborz Jahanian- (void)a:(id *)objects b:(id *)keys; 1201cbe441SFariborz Jahanian@end 1301cbe441SFariborz Jahanian 1401cbe441SFariborz Jahanian@implementation Foo 1501cbe441SFariborz Jahanian- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context { 1601cbe441SFariborz Jahanian id item; 1701cbe441SFariborz Jahanian id obj; 1801cbe441SFariborz Jahanian func(item, obj, context); 1901cbe441SFariborz Jahanian} 2001cbe441SFariborz Jahanian 2101cbe441SFariborz Jahanian- (void)a:(id *)objects b:(id *)keys { 2201cbe441SFariborz Jahanian VoidStar dict; 2301cbe441SFariborz Jahanian id key; 2401cbe441SFariborz Jahanian RandomFunc((CFMDRef)dict, key, objects[3]); 2501cbe441SFariborz Jahanian} 2601cbe441SFariborz Jahanian@end 27b397e43dSFariborz Jahanian 28b397e43dSFariborz Jahanian@interface I 294f4946aaSDouglas Gregor- (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}} 30b397e43dSFariborz Jahanian@end 31b397e43dSFariborz Jahanian 32938cebc0SChris Lattnervoid Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'const I *' to 'I *' for 1st argument}} 33b397e43dSFariborz Jahanian 34b397e43dSFariborz Jahanianvoid foo(const I *p, I* sel) { 35938cebc0SChris Lattner [sel Meth : p]; // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'const I *'}} 36b397e43dSFariborz Jahanian Func(p); // expected-error {{no matching function for call to 'Func'}} 37b397e43dSFariborz Jahanian} 38b397e43dSFariborz Jahanian 3956f2e34aSDouglas Gregor@interface DerivedFromI : I 4056f2e34aSDouglas Gregor@end 4156f2e34aSDouglas Gregor 428d6d0676SDouglas Gregorvoid accept_derived(DerivedFromI*); 4356f2e34aSDouglas Gregor 4456f2e34aSDouglas Gregorvoid test_base_to_derived(I* i) { 456dd3a6a1SDouglas Gregor accept_derived(i); // expected-warning{{incompatible pointer types passing 'I *' to parameter of type 'DerivedFromI *'}} 46413e064bSFariborz Jahanian DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'DerivedFromI *' with an expression of type 'I *'}} 476dd3a6a1SDouglas Gregor DerivedFromI *di2 = (DerivedFromI *)i; 4856f2e34aSDouglas Gregor} 49