1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
2 /* { dg-do compile } */
3 /* { dg-additional-options "-Wno-objc-root-class" } */
7 /* Test that @optional for @protocol works. */
13 + (int)optionalClassMethod;
14 - (int)optionalMethod;
17 @interface MyRootClass <MyProtocol>
20 /* The implementation implements both the @required methods, but none
21 of the @optional ones. There should be no warnings as the
22 @optional methods are optional. ;-) */
23 @implementation MyRootClass
34 int function (id <MyProtocol> object1,
37 /* Test that there are no warnings if you try to use an @optional
38 method with an object of the class. */
41 i += [object1 method];
42 i += [object2 method];
43 i += [MyRootClass classMethod];
44 i += [object1 optionalMethod];
45 i += [object2 optionalMethod];
46 i += [MyRootClass optionalClassMethod];