aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2025-04-09 13:22:56 -0400
committerJason Merrill <jason@redhat.com>2025-04-10 10:04:46 -0400
commit39892d9618ee0f06dd09271589878b0df7b1e75d (patch)
treebd5cd5884fb4471ba5f56ebc6d9f5b85118e2871 /gcc
parent911973a784aab34e13c683545f28177d0d7716cd (diff)
downloadgcc-39892d9618ee0f06dd09271589878b0df7b1e75d.zip
gcc-39892d9618ee0f06dd09271589878b0df7b1e75d.tar.gz
gcc-39892d9618ee0f06dd09271589878b0df7b1e75d.tar.bz2
c++: lambda in constraint of lambda [PR119175]
Here when we went to mangle the constraints of from<0>, the outer lambda has no mangling scope, but the inner one was treated as having the outer one as its scope. And mangling the outer one means mangling its constraints, which include the inner one. So infinite recursion. But a lambda closure type isn't a scope that anything should have for mangling, the inner lambda should also have no mangling scope. PR c++/119175 gcc/cp/ChangeLog: * mangle.cc (decl_mangling_context): Look through lambda type. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-lambda23.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/mangle.cc6
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/concepts-lambda23.C12
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 02129c6..3d5e96b 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -1048,6 +1048,12 @@ decl_mangling_context (tree decl)
tree extra = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (decl));
if (extra)
return extra;
+ tcontext = CP_DECL_CONTEXT (decl);
+ if (LAMBDA_TYPE_P (tcontext))
+ /* Lambda type context means this lambda appears between the
+ lambda-introducer and the open brace of another lambda (c++/119175).
+ That isn't a real scope; look further into the enclosing scope. */
+ return decl_mangling_context (TYPE_NAME (tcontext));
}
else if (template_type_parameter_p (decl))
/* template type parms have no mangling context. */
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-lambda23.C b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda23.C
new file mode 100644
index 0000000..f442120
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda23.C
@@ -0,0 +1,12 @@
+// PR c++/119175
+// { dg-do compile { target c++20 } }
+
+template<int = 0>
+static void from() requires requires {
+ []<int> requires requires { [] {}; } {};
+}
+{}
+
+int main() {
+ from();
+}