From b87faffdb9bc86c4c08224bdbaa37096edcfda4d Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Thu, 28 Apr 2016 23:50:12 +0000 Subject: [Sema] Fix a crash that occurs when a variable template is initialized with a generic lambda. This patch fixes Sema::InstantiateVariableInitializer to switch to the context of the variable before instantiating its initializer, which is necessary to set the correct type for VarTemplateSpecializationDecl. This is the first part of the patch that was reviewed here: http://reviews.llvm.org/D19175 rdar://problem/23440346 llvm-svn: 267956 --- clang/test/SemaCXX/vartemplate-lambda.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 clang/test/SemaCXX/vartemplate-lambda.cpp (limited to 'clang/test/SemaCXX') diff --git a/clang/test/SemaCXX/vartemplate-lambda.cpp b/clang/test/SemaCXX/vartemplate-lambda.cpp new file mode 100644 index 00000000000..d5ad155d0e3 --- /dev/null +++ b/clang/test/SemaCXX/vartemplate-lambda.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s +// expected-no-diagnostics + +template auto fn1 = [](auto a) { return a + T(1); }; + +template +int foo2() { + X a = 0x61; + fn1(a); + return 0; +} + +int main() { + foo2(); +} -- cgit v1.2.3