xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/class-method-lookup.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface MyBase
4*f4a2713aSLionel Sambuc- (void) rootInstanceMethod;
5*f4a2713aSLionel Sambuc@end
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc@interface MyIntermediate: MyBase
8*f4a2713aSLionel Sambuc@end
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc@interface MyDerived: MyIntermediate
11*f4a2713aSLionel Sambuc- (void) instanceMethod;
12*f4a2713aSLionel Sambuc+ (void) classMethod;
13*f4a2713aSLionel Sambuc@end
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambuc@implementation MyDerived
16*f4a2713aSLionel Sambuc- (void) instanceMethod {
17*f4a2713aSLionel Sambuc}
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc+ (void) classMethod {                    /* If a class method is not found, the root  */
20*f4a2713aSLionel Sambuc    [self rootInstanceMethod];            /* class is searched for an instance method  */
21*f4a2713aSLionel Sambuc    [MyIntermediate rootInstanceMethod];  /* with the same name.                       */
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc    [self instanceMethod];// expected-warning {{'+instanceMethod' not found (return type defaults to 'id')}}
24*f4a2713aSLionel Sambuc    [MyDerived instanceMethod];// expected-warning {{'+instanceMethod' not found (return type defaults to 'id')}}
25*f4a2713aSLionel Sambuc}
26*f4a2713aSLionel Sambuc@end
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc@interface Object @end
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc@interface Class1
31*f4a2713aSLionel Sambuc- (void)setWindow:(Object *)wdw;
32*f4a2713aSLionel Sambuc@end
33*f4a2713aSLionel Sambuc
34*f4a2713aSLionel Sambuc@interface Class2
35*f4a2713aSLionel Sambuc- (void)setWindow:(Class1 *)window;
36*f4a2713aSLionel Sambuc@end
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc#define nil (void*)0
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambucid foo(void) {
41*f4a2713aSLionel Sambuc  Object *obj;
42*f4a2713aSLionel Sambuc  id obj2 = obj;
43*f4a2713aSLionel Sambuc  [obj setWindow:nil]; // expected-warning {{'Object' may not respond to 'setWindow:'}}
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc  return obj;
46*f4a2713aSLionel Sambuc}
47