From: Douglas Gregor Date: Mon, 20 Sep 2010 16:48:21 +0000 (+0000) Subject: Give implicitly-defined default constructors and destructors empty X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ada9d3aa47d66e4074229fb93f24416526a15e8;p=clang Give implicitly-defined default constructors and destructors empty bodies, from Martin Vejnar! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114329 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 4816d22013..4efb62a9d4 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4458,10 +4458,14 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, Diag(CurrentLocation, diag::note_member_synthesized_at) << CXXConstructor << Context.getTagDeclType(ClassDecl); Constructor->setInvalidDecl(); - } else { - Constructor->setUsed(); - MarkVTableUsed(CurrentLocation, ClassDecl); + return; } + + SourceLocation Loc = Constructor->getLocation(); + Constructor->setBody(new (Context) CompoundStmt(Context, 0, 0, Loc, Loc)); + + Constructor->setUsed(); + MarkVTableUsed(CurrentLocation, ClassDecl); } CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) { @@ -4569,6 +4573,9 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation, return; } + SourceLocation Loc = Destructor->getLocation(); + Destructor->setBody(new (Context) CompoundStmt(Context, 0, 0, Loc, Loc)); + Destructor->setUsed(); MarkVTableUsed(CurrentLocation, ClassDecl); }