Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / objc.dg / method-conflict-2.m
blob0b0612d771e030da739b481ea8a04e77b96da103
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
2 /* { dg-do compile } */
4 #include <objc/objc.h>
6 /* Test that you can not declare two methods, in the same protocol,
7    with the same name and method signature, but one as @required and
8    once as @optional.  */
10 /* First, @required conflicting with @optional.  */
11 @protocol MyProtocol
13 @optional
14 + (void) method1: (id)x; /* { dg-message "previous declaration" } */
15 - (id) method2: (long)x; /* { dg-message "previous declaration" } */
17 @required
18 + (void) method1: (id)x; /* { dg-error "declared .@optional. and .@required. at the same time" } */
19 - (id) method2: (long)x; /* { dg-error "declared .@optional. and .@required. at the same time" } */
21 @end
23 /* Second, @optional conflicting with @required.  */
24 @protocol MyProtocol2
26 @required
27 + (void) method3: (Class)x; /* { dg-message "previous declaration" } */
28 - (id *) method4: (long)x;  /* { dg-message "previous declaration" } */
30 @optional
31 + (void) method3: (Class)x; /* { dg-error "declared .@optional. and .@required. at the same time" } */
32 - (id *) method4: (long)x;  /* { dg-error "declared .@optional. and .@required. at the same time" } */
34 @end