OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / method-conflict-1.mm
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 but conflicting method signatures.  */
8
9 @protocol MyProtocol
10 + (int) method1: (int)x;   /* { dg-message "previous declaration" } */
11 + (float) method1: (int)x; /* { dg-error "duplicate declaration of method .\\+method1." } */
12
13 - (int) method2: (int)x;   /* { dg-message "previous declaration" } */
14 - (int) method2: (float)x; /* { dg-error "duplicate declaration of method .\\-method2." } */
15
16 @optional
17 + (int *) method3: (int)x;    /* { dg-message "previous declaration" } */
18 + (int *) method3: (int **)x; /* { dg-error "duplicate declaration of method .\\+method3." } */
19
20 - (id) method4: (id)x;   /* { dg-message "previous declaration" } */
21 - (void) method4: (id)x; /* { dg-error "duplicate declaration of method .\\-method4." } */
22 @end
23
24 /* We don't test conflicting types between @required and @optional
25    methods, as that is tested in method-conflict-2.  */
26