[PATCH] D66067: Push lambda scope earlier when transforming lambda expression
Nicholas Allegra via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 13:31:18 PDT 2019
comex updated this revision to Diff 217230.
comex marked 2 inline comments as done.
comex added a comment.
Addressed review comments.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66067/new/
https://reviews.llvm.org/D66067
Files:
lib/Sema/TreeTransform.h
test/SemaTemplate/default-arguments-cxx0x.cpp
Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===================================================================
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
// expected-no-diagnostics
// Test default template arguments for function templates.
@@ -114,3 +115,17 @@
S<int> _a{};
};
}
+
+#if __cplusplus >= 201402L
+namespace lambda {
+ // Verify that a default argument in a lambda can refer to the type of a
+ // previous `auto` argument without crashing.
+ template <class T>
+ void bar() {
+ (void) [](auto c, int x = sizeof(decltype(c))) {};
+ }
+ void foo() {
+ bar<int>();
+ }
+} // namespace lambda
+#endif
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -11318,10 +11318,14 @@
}
}
+ LambdaScopeInfo *LSI = getSema().PushLambdaScope();
+ Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
+
// Transform the template parameters, and add them to the current
// instantiation scope. The null case is handled correctly.
auto TPL = getDerived().TransformTemplateParameterList(
E->getTemplateParameterList());
+ LSI->GLTemplateParameterList = TPL;
// Transform the type of the original lambda's call operator.
// The transformation MUST be done in the CurrentInstantiationScope since
@@ -11348,10 +11352,6 @@
NewCallOpType);
}
- LambdaScopeInfo *LSI = getSema().PushLambdaScope();
- Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
- LSI->GLTemplateParameterList = TPL;
-
// Create the local class that will describe the lambda.
CXXRecordDecl *OldClass = E->getLambdaClass();
CXXRecordDecl *Class
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66067.217230.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190826/b9d671d5/attachment.bin>
More information about the cfe-commits
mailing list