From 1e23865d0e148a3951a9b418e57b7e0762dc3098 Mon Sep 17 00:00:00 2001 From: Sean Hunt Date: Thu, 12 May 2011 03:51:51 +0000 Subject: [PATCH] Make it so that we actually generate definitions for explicitly defaulted default constructors. As it happens, making sure that we handle out-of-line defaulted functions properly will involved making sure that we actually parse them correctly, so that's coming after. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131224 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 3 ++- lib/Sema/SemaExpr.cpp | 4 ++-- lib/Sema/SemaInit.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 8ef3463f42..13e2819f7b 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5263,6 +5263,7 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor( /*isInline=*/true, /*isImplicitlyDeclared=*/true); DefaultCon->setAccess(AS_public); + DefaultCon->setDefaulted(); DefaultCon->setImplicit(); DefaultCon->setTrivial(ClassDecl->hasTrivialDefaultConstructor()); @@ -5283,7 +5284,7 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor( void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor) { - assert((Constructor->isImplicit() && Constructor->isDefaultConstructor() && + assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() && !Constructor->isUsed(false) && !Constructor->isDeleted()) && "DefineImplicitDefaultConstructor - call it for implicit default ctor"); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 1597152b6c..e2426952b2 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9853,8 +9853,8 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { // Note that this declaration has been used. if (CXXConstructorDecl *Constructor = dyn_cast(D)) { unsigned TypeQuals; - if (Constructor->isImplicit() && Constructor->isDefaultConstructor()) { - if (Constructor->getParent()->hasTrivialDefaultConstructor()) + if (Constructor->isDefaulted() && Constructor->isDefaultConstructor()) { + if (Constructor->isTrivial()) return; if (!Constructor->isUsed(false)) DefineImplicitDefaultConstructor(Loc, Constructor); diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index be3cd34f75..26d030419a 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -4019,7 +4019,7 @@ InitializationSequence::Perform(Sema &S, // the definition for completely trivial constructors. CXXRecordDecl *ClassDecl = Constructor->getParent(); assert(ClassDecl && "No parent class for constructor."); - if (Constructor->isImplicit() && Constructor->isDefaultConstructor() && + if (Constructor->isDefaulted() && Constructor->isDefaultConstructor() && ClassDecl->hasTrivialDefaultConstructor() && !Constructor->isUsed(false)) S.DefineImplicitDefaultConstructor(Loc, Constructor); -- 2.40.0