aboutsummaryrefslogtreecommitdiff
path: root/clang/test
diff options
context:
space:
mode:
authorYupei Liu <liuyupei951018@hotmail.com>2024-07-09 16:39:50 +0800
committerGitHub <noreply@github.com>2024-07-09 16:39:50 +0800
commitf0c7505f597998c84023ccd609ecfc9af3d5b4d6 (patch)
treed1ecea218adda48b63661c81acd52a11b66d75ac /clang/test
parente5865ec93cbf77f84c55e55383ce3254186fc065 (diff)
downloadllvm-f0c7505f597998c84023ccd609ecfc9af3d5b4d6.zip
llvm-f0c7505f597998c84023ccd609ecfc9af3d5b4d6.tar.gz
llvm-f0c7505f597998c84023ccd609ecfc9af3d5b4d6.tar.bz2
[Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (#97215)
Currently, `addInstantiatedParameters` is called from the innermost lambda outward. However, when the function parameters of an inner lambda depend on the function parameters of an outer lambda, it can lead to a crash due to the inability to find a mapping for the instantiated decl. This PR corrects this behavior by calling `addInstantiatedParameters` from the outside in. repro code: https://godbolt.org/z/KbsxWesW6 ```cpp namespace dependent_param_concept { template <typename... Ts> void sink(Ts...) {} void dependent_param() { auto L = [](auto... x) { return [](decltype(x)... y) { // `y` depends on `x` return [](int z) requires requires { sink(y..., z); } {}; }; }; L(0, 1)(1, 2)(1); } } // namespace dependent_param_concept ``` This PR is a prerequisite for implmenting #61426
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaTemplate/concepts-lambda.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp b/clang/test/SemaTemplate/concepts-lambda.cpp
index 280be71..252ef08 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -237,3 +237,17 @@ concept D = []<C T = int>() { return true; }();
D auto x = 0;
} // namespace GH93821
+
+namespace dependent_param_concept {
+template <typename... Ts> void sink(Ts...) {}
+void dependent_param() {
+ auto L = [](auto... x) {
+ return [](decltype(x)... y) {
+ return [](int z)
+ requires requires { sink(y..., z); }
+ {};
+ };
+ };
+ L(0, 1)(1, 2)(1);
+}
+} // namespace dependent_param_concept