]> granicus.if.org Git - clang/commitdiff
Fix a crash when "instantiating" VarDecls that are neither type nor value dependent.
authorAnders Carlsson <andersca@mac.com>
Tue, 24 Nov 2009 16:52:50 +0000 (16:52 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 24 Nov 2009 16:52:50 +0000 (16:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89774 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/CodeGenCXX/member-templates.cpp

index 34dc947422a418df3fa93a760215e6cb854319b3..bda19f1e988f81e1f974c7eeeef285faa5a9f28a 100644 (file)
@@ -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<Expr>());
     }
     else if (ParenListExpr *PLE = dyn_cast<ParenListExpr>((Expr *)Init.get())) {
index d85d6394f0eb53dacb106dca941f1e55d810950b..c8494c42cef9e31689b1099f13bfbe4197c2f1a1 100644 (file)
@@ -18,3 +18,14 @@ template<typename T> B::B(T) {}
 // CHECK: define void @_ZN1BC1IiEET_(%struct.B* %this, i32)
 // CHECK: define void @_ZN1BC2IiEET_(%struct.B* %this, i32)
 template B::B(int);
+
+template<typename T>
+struct C {
+  void f() {
+    int a[] = { 1, 2, 3 };
+  }
+};
+
+void f(C<int>& c) {
+  c.f();
+}