diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-30 20:53:28 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-30 20:53:28 +0000 |
commit | 6c4c36c4ed1007143f5b8655eb68b313a7e12e76 (patch) | |
tree | 0a912935dcb75afa09172e2aabf7b40a71653f2e /lib/Sema/SemaInit.cpp | |
parent | 0f30a12ce7b3d4d86c9ca9072f587da77c8eef34 (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/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 570b240332..125149edc2 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -4482,8 +4482,7 @@ static ExprResult CopyObject(Sema &S, S.Diag(Loc, diag::err_temp_copy_deleted) << (int)Entity.getKind() << CurInitExpr->getType() << CurInitExpr->getSourceRange(); - S.Diag(Best->Function->getLocation(), diag::note_unavailable_here) - << 1 << Best->Function->isDeleted(); + S.NoteDeletedFunction(Best->Function); return ExprError(); } @@ -4592,8 +4591,7 @@ static void CheckCXX98CompatAccessibleCopy(Sema &S, case OR_Deleted: S.Diag(Loc, Diag); - S.Diag(Best->Function->getLocation(), diag::note_unavailable_here) - << 1 << Best->Function->isDeleted(); + S.NoteDeletedFunction(Best->Function); break; } } @@ -5362,26 +5360,6 @@ InitializationSequence::Perform(Sema &S, return move(CurInit); } -/// \brief Provide some notes that detail why a function was implicitly -/// deleted. -static void diagnoseImplicitlyDeletedFunction(Sema &S, CXXMethodDecl *Method) { - // FIXME: This is a work in progress. It should dig deeper to figure out - // why the function was deleted (e.g., because one of its members doesn't - // have a copy constructor, for the copy-constructor case). - if (!Method->isImplicit()) { - S.Diag(Method->getLocation(), diag::note_callee_decl) - << Method->getDeclName(); - } - - if (Method->getParent()->isLambda()) { - S.Diag(Method->getParent()->getLocation(), diag::note_lambda_decl); - return; - } - - S.Diag(Method->getParent()->getLocation(), diag::note_defined_here) - << Method->getParent(); -} - //===----------------------------------------------------------------------===// // Diagnose initialization failures //===----------------------------------------------------------------------===// @@ -5469,8 +5447,7 @@ bool InitializationSequence::Diagnose(Sema &S, = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best, true); if (Ovl == OR_Deleted) { - S.Diag(Best->Function->getLocation(), diag::note_unavailable_here) - << 1 << Best->Function->isDeleted(); + S.NoteDeletedFunction(Best->Function); } else { llvm_unreachable("Inconsistent overload resolution?"); } @@ -5661,20 +5638,15 @@ bool InitializationSequence::Diagnose(Sema &S, // If this is a defaulted or implicitly-declared function, then // it was implicitly deleted. Make it clear that the deletion was // implicit. - if (S.isImplicitlyDeleted(Best->Function)) { + if (S.isImplicitlyDeleted(Best->Function)) S.Diag(Kind.getLocation(), diag::err_ovl_deleted_special_init) - << S.getSpecialMember(cast<CXXMethodDecl>(Best->Function)) + << S.getSpecialMember(cast<CXXMethodDecl>(Best->Function)) << DestType << ArgsRange; - - diagnoseImplicitlyDeletedFunction(S, - cast<CXXMethodDecl>(Best->Function)); - break; - } - - S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init) - << true << DestType << ArgsRange; - S.Diag(Best->Function->getLocation(), diag::note_unavailable_here) - << 1 << Best->Function->isDeleted(); + else + S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init) + << true << DestType << ArgsRange; + + S.NoteDeletedFunction(Best->Function); break; } |