]> granicus.if.org Git - clang/commitdiff
Give implicitly-defined default constructors and destructors empty
authorDouglas Gregor <dgregor@apple.com>
Mon, 20 Sep 2010 16:48:21 +0000 (16:48 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 20 Sep 2010 16:48:21 +0000 (16:48 +0000)
bodies, from Martin Vejnar!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114329 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp

index 4816d22013fa3eaeffa5e255a24a78910c3955aa..4efb62a9d40b150bb3dacfb30e9f74f89e1cabfe 100644 (file)
@@ -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);
 }