forked from OSchip/llvm-project
arc-objc++: Issue an arc specific diagnostic when overload resolution
fails because of lifetime differences of parameter and argument type. // rdar://9790531 llvm-svn: 135593
This commit is contained in:
parent
65080cc55c
commit
a644f9cb73
|
@ -1595,6 +1595,17 @@ def note_ovl_candidate_bad_conv : Note<"candidate "
|
|||
"%select{%ordinal5 argument|object argument}4; "
|
||||
"%select{|dereference the argument with *|"
|
||||
"take the address of the argument with &}6">;
|
||||
def note_ovl_candidate_bad_arc_conv : Note<"candidate "
|
||||
"%select{function|function|constructor|"
|
||||
"function |function |constructor |"
|
||||
"constructor (the implicit default constructor)|"
|
||||
"constructor (the implicit copy constructor)|"
|
||||
"constructor (the implicit move constructor)|"
|
||||
"function (the implicit copy assignment operator)|"
|
||||
"function (the implicit move assignment operator)|"
|
||||
"constructor (inherited)}0%1"
|
||||
" not viable: cannot implicitly convert argument of type %2 to %3 for "
|
||||
"%select{%ordinal5 argument|object argument}4 under ARC">;
|
||||
def note_ovl_candidate_bad_addrspace : Note<"candidate "
|
||||
"%select{function|function|constructor|"
|
||||
"function |function |constructor |"
|
||||
|
|
|
@ -6981,8 +6981,21 @@ void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (isa<ObjCObjectPointerType>(CFromTy) &&
|
||||
isa<PointerType>(CToTy)) {
|
||||
Qualifiers FromQs = CFromTy.getQualifiers();
|
||||
Qualifiers ToQs = CToTy.getQualifiers();
|
||||
if (FromQs.getObjCLifetime() != ToQs.getObjCLifetime()) {
|
||||
S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
|
||||
<< (unsigned) FnKind << FnDesc
|
||||
<< (FromExpr ? FromExpr->getSourceRange() : SourceRange())
|
||||
<< FromTy << ToTy << (unsigned) isObjectArgument << I+1;
|
||||
MaybeEmitInheritedConstructorNote(S, Fn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: specialize more based on the kind of mismatch
|
||||
|
||||
// Emit the generic diagnostic and, optionally, add the hints to it.
|
||||
PartialDiagnostic FDiag = S.PDiag(diag::note_ovl_candidate_bad_conv);
|
||||
FDiag << (unsigned) FnKind << FnDesc
|
||||
|
|
|
@ -173,3 +173,22 @@ void test_f9() {
|
|||
const __autoreleasing id& ar3 = unsafe_unretained_a;
|
||||
const __autoreleasing id& ar4 = weak_a;
|
||||
}
|
||||
|
||||
// rdar://9790531
|
||||
void f9790531(void *inClientData); // expected-note {{candidate function not viable: cannot implicitly convert argument of type 'MixerEQGraphTestDelegate *const __strong' to 'void *' for 1st argument under ARC}}
|
||||
void f9790531_1(struct S*inClientData); // expected-note {{candidate function not viable}}
|
||||
void f9790531_2(char * inClientData); // expected-note {{candidate function not viable}}
|
||||
|
||||
@class UIApplication;
|
||||
|
||||
@interface MixerEQGraphTestDelegate
|
||||
- (void)applicationDidFinishLaunching;
|
||||
@end
|
||||
|
||||
@implementation MixerEQGraphTestDelegate
|
||||
- (void)applicationDidFinishLaunching {
|
||||
f9790531(self); // expected-error {{no matching function for call to 'f9790531'}}
|
||||
f9790531_1(self); // expected-error {{no matching function for call to 'f9790531_1'}}
|
||||
f9790531_2(self); // expected-error {{no matching function for call to 'f9790531_2'}}
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue