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