forked from OSchip/llvm-project
Print optional message for attr(unavailable) in C++ mode.
// rdar://9046492 llvm-svn: 126499
This commit is contained in:
parent
a6ce608b97
commit
bff158dc67
|
@ -1312,6 +1312,8 @@ def err_ovl_ambiguous_call : Error<
|
|||
"call to %0 is ambiguous">;
|
||||
def err_ovl_deleted_call : Error<
|
||||
"call to %select{unavailable|deleted}0 function %1">;
|
||||
def err_ovl_unavailable_call : Error<
|
||||
"call to unavailable function %0: %1">;
|
||||
def err_ovl_ambiguous_member_call : Error<
|
||||
"call to member function %0 is ambiguous">;
|
||||
def err_ovl_deleted_member_call : Error<
|
||||
|
|
|
@ -7709,11 +7709,24 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
|
|||
break;
|
||||
|
||||
case OR_Deleted:
|
||||
Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call)
|
||||
<< Best->Function->isDeleted()
|
||||
<< ULE->getName()
|
||||
<< Fn->getSourceRange();
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
|
||||
{
|
||||
llvm::StringRef Message;
|
||||
if (const UnavailableAttr *UA =
|
||||
Best->Function->getAttr<UnavailableAttr>())
|
||||
Message = UA->getMessage();
|
||||
|
||||
if (Message.empty())
|
||||
Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call)
|
||||
<< Best->Function->isDeleted()
|
||||
<< ULE->getName()
|
||||
<< Fn->getSourceRange();
|
||||
else
|
||||
Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_unavailable_call)
|
||||
<< ULE->getName()
|
||||
<< Message
|
||||
<< Fn->getSourceRange();
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,3 +18,14 @@ void test_foo(short* sp) {
|
|||
int &(*fp3)(int) = foo;
|
||||
void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}}
|
||||
}
|
||||
|
||||
namespace radar9046492 {
|
||||
// rdar://9046492
|
||||
#define FOO __attribute__((unavailable("not available - replaced")))
|
||||
|
||||
void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}}
|
||||
|
||||
void bar() {
|
||||
foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue