OSDN Git Service

* lib/gcc-simulate-thread.exp: New.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / method-conflict-2.m
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
2 /* { dg-do compile } */
3
4 #include <objc/objc.h>
5
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.  */
9
10 /* First, @required conflicting with @optional.  */
11 @protocol MyProtocol
12
13 @optional
14 + (void) method1: (id)x; /* { dg-message "previous declaration" } */
15 - (id) method2: (long)x; /* { dg-message "previous declaration" } */
16
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" } */
20
21 @end
22
23 /* Second, @optional conflicting with @required.  */
24 @protocol MyProtocol2
25
26 @required
27 + (void) method3: (Class)x; /* { dg-message "previous declaration" } */
28 - (id *) method4: (long)x;  /* { dg-message "previous declaration" } */
29
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" } */
33
34 @end