|
|
6608a3 |
From 55f40d968b0bd3be4478a9481e829a99ee0fa04f Mon Sep 17 00:00:00 2001
|
|
|
6608a3 |
From: Jason Merrill <jason@redhat.com>
|
|
|
6608a3 |
Date: Mon, 5 Apr 2021 22:50:44 -0400
|
|
|
6608a3 |
Subject: [PATCH] c++: mangling of lambdas in default args [PR91241]
|
|
|
6608a3 |
|
|
|
6608a3 |
In this testcase, the parms remembered in LAMBDA_EXPR_EXTRA_SCOPE are no
|
|
|
6608a3 |
longer the parms of the FUNCTION_DECL they have as their DECL_CONTEXT, so we
|
|
|
6608a3 |
were mangling both lambdas as parm #0. But since the parms are numbered
|
|
|
6608a3 |
from right to left we don't need to need to find them in the FUNCTION_DECL,
|
|
|
6608a3 |
we can measure their own DECL_CHAIN.
|
|
|
6608a3 |
|
|
|
6608a3 |
gcc/cp/ChangeLog:
|
|
|
6608a3 |
|
|
|
6608a3 |
PR c++/91241
|
|
|
6608a3 |
* mangle.c (write_compact_number): Add sanity check.
|
|
|
6608a3 |
(write_local_name): Use list_length for parm number.
|
|
|
6608a3 |
|
|
|
6608a3 |
gcc/testsuite/ChangeLog:
|
|
|
6608a3 |
|
|
|
6608a3 |
PR c++/91241
|
|
|
6608a3 |
* g++.dg/abi/lambda-defarg1.C: New test.
|
|
|
6608a3 |
---
|
|
|
6608a3 |
gcc/cp/mangle.c | 11 ++---------
|
|
|
6608a3 |
gcc/testsuite/g++.dg/abi/lambda-defarg1.C | 11 +++++++++++
|
|
|
6608a3 |
2 files changed, 13 insertions(+), 9 deletions(-)
|
|
|
6608a3 |
create mode 100644 gcc/testsuite/g++.dg/abi/lambda-defarg1.C
|
|
|
6608a3 |
|
|
|
6608a3 |
--- gcc/cp/mangle.c
|
|
|
6608a3 |
+++ gcc/cp/mangle.c
|
|
|
6608a3 |
@@ -1628,6 +1628,7 @@ write_literal_operator_name (tree identifier)
|
|
|
6608a3 |
static void
|
|
|
6608a3 |
write_compact_number (int num)
|
|
|
6608a3 |
{
|
|
|
6608a3 |
+ gcc_checking_assert (num >= 0);
|
|
|
6608a3 |
if (num > 0)
|
|
|
6608a3 |
write_unsigned_number (num - 1);
|
|
|
6608a3 |
write_char ('_');
|
|
|
6608a3 |
@@ -2027,15 +2028,7 @@ write_local_name (tree function, const tree local_entity,
|
|
|
6608a3 |
/* For this purpose, parameters are numbered from right-to-left. */
|
|
|
6608a3 |
if (parm)
|
|
|
6608a3 |
{
|
|
|
6608a3 |
- tree t;
|
|
|
6608a3 |
- int i = 0;
|
|
|
6608a3 |
- for (t = DECL_ARGUMENTS (function); t; t = DECL_CHAIN (t))
|
|
|
6608a3 |
- {
|
|
|
6608a3 |
- if (t == parm)
|
|
|
6608a3 |
- i = 1;
|
|
|
6608a3 |
- else if (i)
|
|
|
6608a3 |
- ++i;
|
|
|
6608a3 |
- }
|
|
|
6608a3 |
+ int i = list_length (parm);
|
|
|
6608a3 |
write_char ('d');
|
|
|
6608a3 |
write_compact_number (i - 1);
|
|
|
6608a3 |
}
|
|
|
6608a3 |
--- /dev/null
|
|
|
6608a3 |
+++ gcc/testsuite/g++.dg/abi/lambda-defarg1.C
|
|
|
6608a3 |
@@ -0,0 +1,11 @@
|
|
|
6608a3 |
+// PR c++/91241
|
|
|
6608a3 |
+// { dg-do compile { target c++11 } }
|
|
|
6608a3 |
+
|
|
|
6608a3 |
+struct A {
|
|
|
6608a3 |
+ int *b(const int & = []() -> int { return 0; }(),
|
|
|
6608a3 |
+ const int & = []() -> int { return 0; }());
|
|
|
6608a3 |
+};
|
|
|
6608a3 |
+int *A::b(const int &, const int &) { b(); return 0; }
|
|
|
6608a3 |
+// { dg-final { scan-assembler "_ZN1A1bERKiS1_" } }
|
|
|
6608a3 |
+// { dg-final { scan-assembler "_ZZN1A1bERKiS1_Ed_NKUlvE_clEv" } }
|
|
|
6608a3 |
+// { dg-final { scan-assembler "_ZZN1A1bERKiS1_Ed0_NKUlvE_clEv" } }
|
|
|
6608a3 |
--
|
|
|
6608a3 |
2.27.0
|