| 1 |
/* Test whether casting 'id' to a specific class removes method lookup |
| 2 |
ambiguity. */ |
| 3 |
/* Author: Ziemowit Laski <[email protected]>. */ |
| 4 |
|
| 5 |
/* { dg-do compile } */ |
| 6 |
// { dg-additional-options "-Wno-objc-root-class" } |
| 7 |
|
| 8 |
#include <objc/objc.h> |
| 9 |
|
| 10 |
@class Int1, Int2; |
| 11 |
|
| 12 |
@interface Int1 |
| 13 |
+ (Int1 *)classMethod1; |
| 14 |
+ (id)classMethod2; |
| 15 |
- (Int1 *)instanceMethod:(Int2 *)arg; /* { dg-bogus "using" } */ |
| 16 |
@end |
| 17 |
|
| 18 |
@interface Int2: Int1 |
| 19 |
+ (Int1 *)classMethod1; |
| 20 |
+ (id)classMethod2; |
| 21 |
- (id)int2Method; |
| 22 |
- (int)instanceMethod:(int)arg; /* { dg-bogus "also found" } */ |
| 23 |
@end |
| 24 |
|
| 25 |
int main(void) { |
| 26 |
id i = [(Int2 *)[Int1 classMethod1] int2Method]; /* { dg-line i_def } */ |
| 27 |
/* { dg-bogus "may not respond to" "" { target *-*-* } i_def } */ |
| 28 |
int j = [(Int2 *)[Int2 classMethod2] instanceMethod: 45]; /* { dg-bogus "multiple methods" } */ |
| 29 |
/* { dg-bogus "invalid conversion" "" { target *-*-* } i_def } */ |
| 30 |
/* { dg-bogus "invalid conversion" "" { target *-*-* } i_def } */ |
| 31 |
return j; |
| 32 |
} |