2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc / execute / formal_protocol-2.m
blobf399555ed1432e4a6fd1f692689c00df99e6c7d1
1 /* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
2 #include <objc/objc.h>
3 #include <objc/Object.h>
5 /* Test defining a protocol, a class adopting it, and using an object
6    of type `id <protocol>'. */
8 @protocol Enabling
9 - (BOOL) isEnabled;
10 - (void) setEnabled: (BOOL)flag;
11 @end
13 @interface Feature : Object <Enabling>
15   const char *name;
16   BOOL isEnabled;
18 @end
20 @implementation Feature
21 - (BOOL) isEnabled
23   return isEnabled;
25 - (void) setEnabled: (BOOL)flag
27   isEnabled = flag;
29 @end
31 int main (void)
33   id <Enabling> object;
35   object = [Feature new];
37   [object setEnabled: YES];
38   if (![object isEnabled])
39     {
40       abort ();
41     }
43   return 0;