From: Sean Hunt Date: Mon, 23 May 2011 23:56:01 +0000 (+0000) Subject: Delete the extraneous return statement that was causing my earlier X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2545ce1c76236c2277b90dbd4f7d01ef13fe0823;p=clang Delete the extraneous return statement that was causing my earlier issues and also add a test. We should now handle defaulted members of templates properly. No comment as to whether or not this also holds for templated functions, but defaulting those is kind of insane. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131938 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 2481bd004d..701493cf98 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2439,8 +2439,6 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, ActOnFinishFunctionBody(Function, 0, /*IsInstantiation=*/true); SetDeclDefaulted(Function, PatternDecl->getLocation()); - - return; } else { // If this is a constructor, instantiate the member initializers. if (const CXXConstructorDecl *Ctor = diff --git a/test/CodeGenCXX/cxx0x-defaulted-templates.cpp b/test/CodeGenCXX/cxx0x-defaulted-templates.cpp new file mode 100644 index 0000000000..3d4000e499 --- /dev/null +++ b/test/CodeGenCXX/cxx0x-defaulted-templates.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++0x -emit-llvm -o - %s | FileCheck %s + +template +struct X { + X(); +}; + +// CHECK: define void @_ZN1XIbEC1Ev +// CHECK: define void @_ZN1XIbEC2Ev +template <> X::X() = default; + +// CHECK: define weak_odr void @_ZN1XIiEC1Ev +// CHECK: define weak_odr void @_ZN1XIiEC2Ev +template X::X() = default; +template X::X(); + +// CHECK: define linkonce_odr void @_ZN1XIcEC1Ev +// CHECK: define linkonce_odr void @_ZN1XIcEC2Ev +X x;