diff options
-rw-r--r-- | lib/Sema/SemaLambda.cpp | 4 | ||||
-rw-r--r-- | test/CodeGenCXX/lambda-expressions.cpp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index d1f87a2c18..6d54d403aa 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -28,7 +28,7 @@ CXXRecordDecl *Sema::createLambdaClosureType(SourceRange IntroducerRange) { // Start constructing the lambda class. CXXRecordDecl *Class = CXXRecordDecl::CreateLambda(Context, DC, IntroducerRange.getBegin()); - CurContext->addDecl(Class); + DC->addDecl(Class); return Class; } @@ -65,7 +65,7 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, // Temporarily set the lexical declaration context to the current // context, so that the Scope stack matches the lexical nesting. - Method->setLexicalDeclContext(Class->getDeclContext()); + Method->setLexicalDeclContext(CurContext); // Add parameters. if (!Params.empty()) { diff --git a/test/CodeGenCXX/lambda-expressions.cpp b/test/CodeGenCXX/lambda-expressions.cpp index 6f0fa87bb1..5a68e893d7 100644 --- a/test/CodeGenCXX/lambda-expressions.cpp +++ b/test/CodeGenCXX/lambda-expressions.cpp @@ -3,6 +3,9 @@ // CHECK: @var = internal global auto var = [](int i) { return i+1; }; +// CHECK: @cvar = global +extern "C" auto cvar = []{}; + int a() { return []{ return 1; }(); } // CHECK: define i32 @_Z1av // CHECK: call i32 @_ZZ1avENKUlvE_clEv |