From: Eli Friedman Date: Mon, 9 Nov 2009 03:59:26 +0000 (+0000) Subject: Add hack to make the given testcase work. As far as I can tell, this change is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb4a33cdf6342110811ae16f7ca6accababf432f;p=clang Add hack to make the given testcase work. As far as I can tell, this change is reasonably safe, but it doesn't seem like the right solution. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86508 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 641ea24427..33d262311c 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -188,11 +188,13 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { Var->setInvalidDecl(); else if (!D->getType()->isDependentType() && !D->getInit()->isTypeDependent() && - !D->getInit()->isValueDependent()) { + !D->getInit()->isValueDependent() && + !isa(D->getInit())) { // If neither the declaration's type nor its initializer are dependent, // 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. + // FIXME: The InitListExpr handling here is a hack! Var->setInit(SemaRef.Context, Init.takeAs()); } else if (ParenListExpr *PLE = dyn_cast((Expr *)Init.get())) { diff --git a/test/CodeGenCXX/instantiate-init-list.cpp b/test/CodeGenCXX/instantiate-init-list.cpp new file mode 100644 index 0000000000..7d5458af1f --- /dev/null +++ b/test/CodeGenCXX/instantiate-init-list.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc %s -emit-llvm-only -verify + +struct F { + void (*x)(); +}; +void G(); +template class A { + A(); +}; +template A::A() { + static F f = { G }; +} +A a;