aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-30 20:53:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-30 20:53:28 +0000
commit6c4c36c4ed1007143f5b8655eb68b313a7e12e76 (patch)
tree0a912935dcb75afa09172e2aabf7b40a71653f2e /lib/Sema/SemaExpr.cpp
parent0f30a12ce7b3d4d86c9ca9072f587da77c8eef34 (diff)
PR10217: Provide diagnostics explaining why an implicitly-deleted special
member function is deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 88ef8cd5d8..97cb647229 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -108,6 +108,25 @@ static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S,
return Result;
}
+/// \brief Emit a note explaining that this function is deleted or unavailable.
+void Sema::NoteDeletedFunction(FunctionDecl *Decl) {
+ CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Decl);
+
+ if (Method && Method->isImplicit()) {
+ CXXSpecialMember CSM = getSpecialMember(Method);
+ // It is possible for us to no longer be able to determine why the special
+ // member function was deleted, due to a field or base class having acquired
+ // a new special member function by the addition of a default argument.
+ // FIXME: Add a test and a special-case diagnostic for this.
+ if (CSM != CXXInvalid &&
+ ShouldDeleteSpecialMember(Method, CSM, /*Diagnose=*/true))
+ return;
+ }
+
+ Diag(Decl->getLocation(), diag::note_unavailable_here)
+ << 1 << Decl->isDeleted();
+}
+
/// \brief Determine whether the use of this declaration is valid, and
/// emit any corresponding diagnostics.
///
@@ -151,7 +170,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->isDeleted()) {
Diag(Loc, diag::err_deleted_function_use);
- Diag(D->getLocation(), diag::note_unavailable_here) << 1 << true;
+ NoteDeletedFunction(FD);
return true;
}
}