2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc / execute / formal_protocol-1.m
blob1fde38b794d657b4a936ec794c459c46083d83b0
1 /* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
2 #include <objc/objc.h>
3 #include <objc/Object.h>
5 /* Tests defining a protocol and a class adopting it */
7 @protocol Enabling
8 - (BOOL) isEnabled;
9 - (void) setEnabled: (BOOL)flag;
10 @end
12 @interface Feature : Object <Enabling>
14   const char *name;
15   BOOL isEnabled;
17 @end
19 @implementation Feature
20 - (BOOL) isEnabled
22   return isEnabled;
24 - (void) setEnabled: (BOOL)flag
26   isEnabled = flag;
28 @end
30 int main (void)
32   Feature *object;
34   object = [Feature new];
36   [object setEnabled: YES];
37   if (![object isEnabled])
38     {
39       abort ();
40     }
42   return 0;