diff options
author | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2011-05-12 03:51:48 +0000 |
---|---|---|
committer | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2011-05-12 03:51:48 +0000 |
commit | ca46d131aa40ae953d719b096cb951b385787445 (patch) | |
tree | 539ccbe94629c0f5bc7d33939b74d2e866a323a3 /lib/Sema/SemaDecl.cpp | |
parent | 8a29bc047a374df2464869b55581c24def68c2ec (diff) |
Implement deletion of explicitly defaulted default constructors.
We still don't parse out-of-line defaults correctly, which is needed to
get the full effect out of this patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131223 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 9a4afde057..972d080fc9 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1518,7 +1518,6 @@ Sema::CXXSpecialMember Sema::getSpecialMember(const CXXMethodDecl *MD) { if (MD->isCopyAssignmentOperator()) return Sema::CXXCopyAssignment; - llvm_unreachable("getSpecialMember on non-special member"); return Sema::CXXInvalid; } @@ -4220,9 +4219,6 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, isVirtualOkay = !isStatic; } else { - if (DefaultLoc.isValid()) - Diag(DefaultLoc, diag::err_default_special_members); - // Determine whether the function was written with a // prototype. This true when: // - we're in C++ (where every function has a prototype), @@ -4778,33 +4774,13 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, } } - // Check explicitly defaulted methods - // FIXME: This could be made better through CXXSpecialMember if it did - // default constructors (which it should rather than any constructor). - if (NewFD && DefaultLoc.isValid() && getLangOptions().CPlusPlus) { - if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD)) { - if (CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(MD)) { - if (CD->isDefaultConstructor() || CD->isCopyOrMoveConstructor()) { - CD->setDefaulted(); - CD->setExplicitlyDefaulted(); - if (CD != CD->getCanonicalDecl() && CD->isDefaultConstructor()) - CheckExplicitlyDefaultedDefaultConstructor(CD); - // FIXME: Do copy/move ctors here. - } else { - Diag(DefaultLoc, diag::err_default_special_members); - } - } else if (CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) { - DD->setDefaulted(); - DD->setExplicitlyDefaulted(); - // FIXME: Add a checking method - } else if (MD->isCopyAssignmentOperator() /* || - MD->isMoveAssignmentOperator() */) { - MD->setDefaulted(); - MD->setExplicitlyDefaulted(); - // FIXME: Add a checking method - } else { - Diag(DefaultLoc, diag::err_default_special_members); - } + if (DefaultLoc.isValid()) { + CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD); + if (MD && getSpecialMember(MD) != CXXInvalid) { + MD->setExplicitlyDefaulted(); + MD->setDefaulted(); + } else { + Diag(DefaultLoc, diag::err_default_special_members); } } |