From b7408b95edfeb6633db21d58e59d6a642cb73f1b Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 24 Nov 2009 16:52:50 +0000 Subject: [PATCH] Fix a crash when "instantiating" VarDecls that are neither type nor value dependent. llvm-svn: 89774 --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 1 + clang/test/CodeGenCXX/member-templates.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 34dc947422a4..bda19f1e988f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/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/clang/test/CodeGenCXX/member-templates.cpp b/clang/test/CodeGenCXX/member-templates.cpp index d85d6394f0eb..c8494c42cef9 100644 --- a/clang/test/CodeGenCXX/member-templates.cpp +++ b/clang/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(); +}