aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorSimon Martin <simon@nasilyan.com>2024-09-16 13:45:32 +0200
committerSimon Martin <simon@nasilyan.com>2024-09-23 15:05:48 +0200
commita030fcad4f9f490a08db0a4cad4c22635a0585c1 (patch)
tree54bf220b752e67c228e461fbe8a8ab22f60bd441 /gcc/cp
parentd7bf5e53887a467b8c5c8439e5aae3ad4e11e62e (diff)
downloadgcc-a030fcad4f9f490a08db0a4cad4c22635a0585c1.zip
gcc-a030fcad4f9f490a08db0a4cad4c22635a0585c1.tar.gz
gcc-a030fcad4f9f490a08db0a4cad4c22635a0585c1.tar.bz2
c++: Don't crash when mangling member with anonymous union or template type [PR100632, PR109790]
We currently crash upon mangling members that have an anonymous union or a template operator type. The problem is that before calling write_unqualified_name, write_member_name asserts that it has a declaration whose DECL_NAME is an identifier node that is not that of an operator. This is wrong: - In PR100632, it's an anonymous union declaration, hence a 0 DECL_NAME - In PR109790, it's a legitimate template declaration for an operator (this was accepted up to GCC 10) This assert was added via r11-6301, to be sure that we do write the "on" marker for operator members. This patch removes that assert and instead - Lets members with an anonymous union type go through - For operators, adds the missing "on" marker for ABI versions greater than the highest usable with GCC 10 PR c++/109790 PR c++/100632 gcc/cp/ChangeLog: * mangle.cc (write_member_name): Handle members whose type is an anonymous union member. Write missing "on" marker for operators when ABI version is at least 16. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/decltype83.C: New test. * g++.dg/cpp0x/decltype83a.C: New test. * g++.dg/cpp1y/lambda-ice3.C: New test. * g++.dg/cpp1y/lambda-ice3a.C: New test. * g++.dg/cpp2a/nontype-class67.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/mangle.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 46dc692..17988d69 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -3255,7 +3255,13 @@ write_member_name (tree member)
}
else if (DECL_P (member))
{
- gcc_assert (!DECL_OVERLOADED_OPERATOR_P (member));
+ if (ANON_AGGR_TYPE_P (TREE_TYPE (member)))
+ ;
+ else if (DECL_OVERLOADED_OPERATOR_P (member))
+ {
+ if (abi_check (16))
+ write_string ("on");
+ }
write_unqualified_name (member);
}
else if (TREE_CODE (member) == TEMPLATE_ID_EXPR)