xref: /aosp_15_r20/external/clang/test/SemaObjC/super-property-notation.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li
3*67e74705SXin Li@interface B
4*67e74705SXin Li+(int) classGetter;
5*67e74705SXin Li-(int) getter;
6*67e74705SXin Li@end
7*67e74705SXin Li
8*67e74705SXin Li@interface A : B
9*67e74705SXin Li@end
10*67e74705SXin Li
11*67e74705SXin Li@implementation A
12*67e74705SXin Li+(int) classGetter {
13*67e74705SXin Li  return 0;
14*67e74705SXin Li}
15*67e74705SXin Li
16*67e74705SXin Li+(int) classGetter2 {
17*67e74705SXin Li  return super.classGetter;
18*67e74705SXin Li}
19*67e74705SXin Li
20*67e74705SXin Li-(void) method {
21*67e74705SXin Li  int x = super.getter;
22*67e74705SXin Li}
23*67e74705SXin Li@end
24*67e74705SXin Li
25*67e74705SXin Livoid f0() {
26*67e74705SXin Li  // FIXME: not implemented yet.
27*67e74705SXin Li  //int l1 = A.classGetter;
28*67e74705SXin Li  int l2 = [A classGetter2];
29*67e74705SXin Li}
30*67e74705SXin Li
31*67e74705SXin Li// rdar://13349296
32*67e74705SXin Li__attribute__((objc_root_class)) @interface ClassBase
33*67e74705SXin Li@property (nonatomic, retain) ClassBase * foo; // expected-note {{property declared here}}
34*67e74705SXin Li@end
35*67e74705SXin Li
36*67e74705SXin Li@implementation ClassBase
37*67e74705SXin Li- (void) Meth:(ClassBase*)foo {
38*67e74705SXin Li  super.foo = foo; // expected-error {{'ClassBase' cannot use 'super' because it is a root class}}
39*67e74705SXin Li  [super setFoo:foo]; // expected-error {{'ClassBase' cannot use 'super' because it is a root class}}
40*67e74705SXin Li}
41*67e74705SXin Li@end
42*67e74705SXin Li
43*67e74705SXin Li@interface ClassDerived : ClassBase
44*67e74705SXin Li@property (nonatomic, retain) ClassDerived * foo; // expected-warning {{auto property synthesis will not synthesize property 'foo'; it will be implemented by its superclass}}
45*67e74705SXin Li@end
46*67e74705SXin Li
47*67e74705SXin Li@implementation ClassDerived // expected-note {{detected while default synthesizing properties in class implementation}}
48*67e74705SXin Li- (void) Meth:(ClassBase*)foo {
49*67e74705SXin Li  super.foo = foo; // must work with no warning
50*67e74705SXin Li  [super setFoo:foo]; // works with no warning
51*67e74705SXin Li}
52*67e74705SXin Li@end
53*67e74705SXin Li
54*67e74705SXin Li@implementation IFaceNotFound (Foo) // expected-error {{cannot find interface declaration for 'IFaceNotFound'}}
55*67e74705SXin Li-(int) foo {
56*67e74705SXin Li  return super.foo; // expected-error {{expected identifier or '('}}
57*67e74705SXin Li}
58*67e74705SXin Li@end
59