From: Anders Carlsson Date: Tue, 24 Nov 2009 16:52:50 +0000 (+0000) Subject: Fix a crash when "instantiating" VarDecls that are neither type nor value dependent. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a244dc3a554f6bf82416697e34f9e96dc1efbb88;p=clang Fix a crash when "instantiating" VarDecls that are neither type nor value dependent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 34dc947422..bda19f1e98 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -205,6 +205,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { // we don't want to redo all the checking, especially since the // initializer might have been wrapped by a CXXConstructExpr since we did // it the first time. + Var->setType(D->getType()); Var->setInit(SemaRef.Context, Init.takeAs()); } else if (ParenListExpr *PLE = dyn_cast((Expr *)Init.get())) { diff --git a/test/CodeGenCXX/member-templates.cpp b/test/CodeGenCXX/member-templates.cpp index d85d6394f0..c8494c42ce 100644 --- a/test/CodeGenCXX/member-templates.cpp +++ b/test/CodeGenCXX/member-templates.cpp @@ -18,3 +18,14 @@ template B::B(T) {} // CHECK: define void @_ZN1BC1IiEET_(%struct.B* %this, i32) // CHECK: define void @_ZN1BC2IiEET_(%struct.B* %this, i32) template B::B(int); + +template +struct C { + void f() { + int a[] = { 1, 2, 3 }; + } +}; + +void f(C& c) { + c.f(); +}