From ebdfa9b60d9a89859f4f8a7760510fbe0fc96b53 Mon Sep 17 00:00:00 2001 From: Faisal Vali Date: Sun, 8 Dec 2013 15:00:29 +0000 Subject: [PATCH] Fix an assertion introduced by my previous refactoring. Add back the test that was triggering the assertion (which I removed mistakenly thinking it was triggering just a warning and not an assertion). My error was brought to my attention by Rafael (Thanks!). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196721 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaLambda.cpp | 10 ++++------ test/SemaCXX/cxx1y-init-captures.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index 0719f4156f..5ed4c6153d 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -181,12 +181,10 @@ Optional clang::getStackIndexOfNearestEnclosingCaptureCapableLambda( return FailDistance; const unsigned IndexOfCaptureReadyLambda = OptionalStackIndex.getValue(); - assert( - ((IndexOfCaptureReadyLambda != (FunctionScopes.size() - 1)) || - (S.getCurGenericLambda() && S.getCurGenericLambda()->ImpCaptureStyle != - sema::LambdaScopeInfo::ImpCap_None)) && - "The capture ready lambda for a potential capture can only be the " - "current lambda if it is a generic lambda with an implicit capture"); + assert(((IndexOfCaptureReadyLambda != (FunctionScopes.size() - 1)) || + S.getCurGenericLambda()) && + "The capture ready lambda for a potential capture can only be the " + "current lambda if it is a generic lambda with an implicit capture"); const sema::LambdaScopeInfo *const CaptureReadyLambdaLSI = cast(FunctionScopes[IndexOfCaptureReadyLambda]); diff --git a/test/SemaCXX/cxx1y-init-captures.cpp b/test/SemaCXX/cxx1y-init-captures.cpp index 2cb4d31ffc..046773f611 100644 --- a/test/SemaCXX/cxx1y-init-captures.cpp +++ b/test/SemaCXX/cxx1y-init-captures.cpp @@ -32,11 +32,18 @@ namespace variadic_expansion { void h(int i, char c) { g(i, c); } //expected-note{{in instantiation}} } +namespace simple_init_captures { + void test() { + int i; + auto L = [i](auto a) { return i + a; }; + L(3.14); + } +} namespace odr_use_within_init_capture { int test() { - + { // no captures const int x = 10; auto L = [z = x + 2](int a) { -- 2.40.0