| 1 |
/* Contributed by Nicola Pero <[email protected]>, December 2010. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
|
| 4 |
#include <objc/objc.h> |
| 5 |
|
| 6 |
/* Test that the compiler can correctly compare protocols in types of |
| 7 |
method signatures. */ |
| 8 |
|
| 9 |
@protocol A, B, C; |
| 10 |
|
| 11 |
@interface MyClass |
| 12 |
- (void) method1: (id)x; |
| 13 |
- (void) method1: (id)x; /* Ok */ |
| 14 |
|
| 15 |
- (void) method2: (id <A>)x; |
| 16 |
- (void) method2: (id <A>)x; /* Ok */ |
| 17 |
|
| 18 |
- (void) method3: (id <A, B>)x; |
| 19 |
- (void) method3: (id <A, B>)x; /* Ok */ |
| 20 |
|
| 21 |
- (void) method4: (id <A, B>)x; |
| 22 |
- (void) method4: (id <A, B, B>)x; /* Ok */ |
| 23 |
|
| 24 |
- (void) method5: (id <A, A, B>)x; |
| 25 |
- (void) method5: (id <A, B, B>)x; /* Ok */ |
| 26 |
|
| 27 |
- (void) method6: (id <A, A, B, B, C, C>)x; |
| 28 |
- (void) method6: (id <C, A, B>)x; /* Ok */ |
| 29 |
|
| 30 |
- (void) method7: (id)x; /* { dg-message "previous declaration" } */ |
| 31 |
- (void) method7: (id <A>)x; /* { dg-error "duplicate declaration" } */ |
| 32 |
|
| 33 |
- (void) method8: (id <A>)x; /* { dg-message "previous declaration" } */ |
| 34 |
- (void) method8: (id)x; /* { dg-error "duplicate declaration" } */ |
| 35 |
|
| 36 |
- (void) method9: (id <A>)x; /* { dg-message "previous declaration" } */ |
| 37 |
- (void) method9: (id <B>)x; /* { dg-error "duplicate declaration" } */ |
| 38 |
|
| 39 |
- (void) methodA: (id <A>)x; /* { dg-message "previous declaration" } */ |
| 40 |
- (void) methodA: (id <A, B>)x; /* { dg-error "duplicate declaration" } */ |
| 41 |
|
| 42 |
- (void) methodB: (id <A, B>)x; /* { dg-message "previous declaration" } */ |
| 43 |
- (void) methodB: (id <A>)x; /* { dg-error "duplicate declaration" } */ |
| 44 |
|
| 45 |
- (void) methodC: (id <A, B, C>)x; /* { dg-message "previous declaration" } */ |
| 46 |
- (void) methodC: (id <A, B>)x; /* { dg-error "duplicate declaration" } */ |
| 47 |
|
| 48 |
- (void) methodD: (id <A, B, C>)x; /* { dg-message "previous declaration" } */ |
| 49 |
- (void) methodD: (id <A, B, A>)x; /* { dg-error "duplicate declaration" } */ |
| 50 |
|
| 51 |
- (void) methodE: (MyClass <A, B, C> *)x; /* { dg-message "previous declaration" } */ |
| 52 |
- (void) methodE: (MyClass <A, B, A> *)x; /* { dg-error "duplicate declaration" } */ |
| 53 |
|
| 54 |
- (void) methodF: (MyClass <A, B, A> *)x; |
| 55 |
- (void) methodF: (MyClass <A, B, A> *)x; /* Ok */ |
| 56 |
|
| 57 |
- (void) methodG: (MyClass *)x; /* { dg-message "previous declaration" } */ |
| 58 |
- (void) methodG: (MyClass <A, B, C> *)x; /* { dg-error "duplicate declaration" } */ |
| 59 |
|
| 60 |
- (void) methodH: (MyClass <A, C>*)x; /* { dg-message "previous declaration" } */ |
| 61 |
- (void) methodH: (MyClass *)x; /* { dg-error "duplicate declaration" } */ |
| 62 |
|
| 63 |
@end |