2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / gcc / testsuite / obj-c++.dg / method-conflict-4.mm
blobe2aca6cc51cc3efc1d12ed751da9b80e8d447965
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
2 /* { dg-do compile } */
4 #include <objc/objc.h>
6 /* Test that the compiler can correctly compare protocols in types of
7    method signatures.  In this test we look at protocols implementing
8    other protocols.  The fact that one protocol implements another one
9    doesn't mean that they are identical.  */
11 @protocol A
12 - (void) doSomething;
13 @end
15 @protocol B <A>
16 - (void) doSomethingElse;
17 @end
19 @protocol C <A>
20 - (void) doYetSomethingElse;
21 @end
23 @interface MyClass2
24 - (void) aMethod: (id <A>)x;  /* { dg-message "previous declaration" } */
25 - (void) aMethod: (id <B>)x;  /* { dg-error "duplicate declaration" } */
27 - (void) bMethod: (id <B>)x;  /* { dg-message "previous declaration" } */
28 - (void) bMethod: (id <A>)x;  /* { dg-error "duplicate declaration" } */
30 - (void) cMethod: (id <A, B>)x;
31 - (void) cMethod: (id <B>)x;  /* Ok - because if you implement B, then you also implement A, so <B> == <A, B> */
33 - (void) dMethod: (id <A, B>)x;
34 - (void) dMethod: (id <B, A>)x; /* Ok */
36 - (void) eMethod: (id <A>)x;    /* { dg-message "previous declaration" } */
37 - (void) eMethod: (id <B, C>)x; /* { dg-error "duplicate declaration" } */
39 - (void) fMethod: (id <B, C>)x;    /* { dg-message "previous declaration" } */
40 - (void) fMethod: (id <A>)x;       /* { dg-error "duplicate declaration" } */
42 - (void) gMethod: (id <A>)x;       /* { dg-message "previous declaration" } */
43 - (void) gMethod: (id <A, B, C>)x; /* { dg-error "duplicate declaration" } */
45 - (void) hMethod: (id <A, B, C>)x; /* { dg-message "previous declaration" } */
46 - (void) hMethod: (id <A>)x;       /* { dg-error "duplicate declaration" } */
47 @end