| 1 |
/* Check that sending messages to variables of type 'Class' does not involve instance methods, unless they reside in root classes. */ |
| 2 |
/* Author: Ziemowit Laski <[email protected]> */ |
| 3 |
/* { dg-options "-Wstrict-selector-match" } */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-skip-if "Object interface removed" { *-*-darwin[1-2]* && { lp64 } } { "-fnext-runtime" } { "" } } */ |
| 6 |
// { dg-additional-options "-Wno-objc-root-class" } |
| 7 |
|
| 8 |
#include <objc/Protocol.h> |
| 9 |
|
| 10 |
@interface Base |
| 11 |
- (unsigned)port; /* { dg-line Base_port } */ |
| 12 |
@end |
| 13 |
|
| 14 |
@interface Derived: Base |
| 15 |
- (Object *)port; |
| 16 |
+ (Protocol *)port; /* { dg-line Derived_port_last } */ |
| 17 |
- (id)starboard; |
| 18 |
@end |
| 19 |
|
| 20 |
void foo(void) { |
| 21 |
Class receiver; |
| 22 |
|
| 23 |
[receiver port]; /* { dg-warning "multiple methods named .\\+port. found" } */ |
| 24 |
/* { dg-message "using .\\-\\(unsigned( int)?\\)port." "" { target *-*-* } Base_port } */ |
| 25 |
/* { dg-message "also found .\\+\\(Protocol \\*\\)port." "" { target *-*-* } Derived_port_last } */ |
| 26 |
|
| 27 |
[receiver starboard]; /* { dg-warning "no .\\+starboard. method found" } */ |
| 28 |
/* { dg-warning "messages without a matching method signature will be assumed to return .id. and accept .\.\.\.. as arguments" "" { target *-*-* } 0 } */ |
| 29 |
|
| 30 |
[Class port]; /* { dg-error ".Class. is not an Objective\\-C class name or alias" } */ |
| 31 |
} |