teak-llvm/clang/test/SemaObjC/warn-messaging-id.mm
Alex Lorenz d9f1284009 [ObjC] Add a -Wobjc-messaging-id warning
-Wobjc-messaging-id is a new, non-default warning that warns about
message sends to unqualified id in Objective-C. This warning is useful
for projects that would like to avoid any potential future compiler
errors/warnings, as the system frameworks might add a method with the same
selector which could make the message send to id ambiguous.

rdar://33303354

llvm-svn: 311779
2017-08-25 16:12:17 +00:00

22 lines
537 B
Plaintext

// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -Wobjc-messaging-id %s
@interface CallMeMaybe
- (void)doThing:(int)intThing;
@property int thing;
@end
template<typename T>
void instantiate(const T &x) {
[x setThing: 22]; // expected-warning {{messaging unqualified id}}
}
void fn() {
id myObject;
[myObject doThing: 10]; // expected-warning {{messaging unqualified id}}
[myObject setThing: 11]; // expected-warning {{messaging unqualified id}}
instantiate(myObject); // expected-note {{in instantiation}}
}