1/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2/* { dg-do compile } */
3
4/* Test warnings and non-warnings with @optional @properties.  */
5
6#include <stdlib.h>
7#include <objc/objc.h>
8#include <objc/runtime.h>
9
10@interface MyRootClass
11{
12  Class isa;
13}
14+ (id) initialize;
15+ (id) alloc;
16- (id) init;
17@end
18
19@implementation MyRootClass
20+ (id) initialize { return self; }
21+ (id) alloc { return class_createInstance (self, 0); }
22- (id) init { return self; }
23@end
24
25@protocol count
26@optional
27@property int count1;
28@property (readonly) int count2;
29@end
30
31
32/* A class that implements all the properties.  */
33@interface MySubClass1 : MyRootClass <count>
34{
35  int count1;
36  int count2;
37}
38@end
39
40@implementation MySubClass1
41@synthesize count1;
42@synthesize count2;
43@end
44
45
46/* A class that implements nothing; no warnings as the properties are
47   all optional.  */
48@interface MySubClass2 : MyRootClass <count>
49@end
50
51@implementation MySubClass2
52@end
53
54
55@protocol count2
56@required
57@property int count1;
58@property (readonly) int count2;
59@end
60
61/* A class that implements all the properties.  */
62@interface MySubClass3 : MyRootClass <count2>
63{
64  int count1;
65  int count2;
66}
67@end
68
69@implementation MySubClass3
70@synthesize count1;
71@synthesize count2;
72@end
73
74
75/* A class that implements nothing; warnings as the properties are
76   all required.  */
77@interface MySubClass4 : MyRootClass <count2>
78@end
79
80@implementation MySubClass4
81@end
82/* { dg-warning "incomplete implementation of class" "" { target *-*-* } .-1 } */
83/* { dg-warning "method definition for ..setCount1:. not found" "" { target *-*-* } .-2 } */
84/* { dg-warning "method definition for ..count1. not found" "" { target *-*-* } .-3 } */
85/* { dg-warning "method definition for ..count2. not found" "" { target *-*-* } .-4 } */
86/* { dg-warning "class .MySubClass4. does not fully implement the .count2. protocol" "" { target *-*-* } .-5 } */
87