* [pushed] c++: mangling union{1} in template [PR104847]
@ 2022-03-28 13:32 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-03-28 13:32 UTC (permalink / raw)
To: gcc-patches
My implementation of union non-type template arguments in r11-2016 broke
braced casts of union type, because they are still in syntactic (undigested)
form.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/104847
gcc/cp/ChangeLog:
* mangle.cc (write_expression): Don't write a union designator when
undigested.
gcc/testsuite/ChangeLog:
* g++.dg/abi/mangle-union1.C: New test.
---
gcc/cp/mangle.cc | 2 +-
gcc/testsuite/g++.dg/abi/mangle-union1.C | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/abi/mangle-union1.C
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index dbcec0a55bc..eb53e0ebeb4 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -3363,7 +3363,7 @@ write_expression (tree expr)
{
if (i > last_nonzero)
break;
- if (TREE_CODE (etype) == UNION_TYPE)
+ if (!undigested && TREE_CODE (etype) == UNION_TYPE)
{
/* Express the active member as a designator. */
write_string ("di");
diff --git a/gcc/testsuite/g++.dg/abi/mangle-union1.C b/gcc/testsuite/g++.dg/abi/mangle-union1.C
new file mode 100644
index 00000000000..f2ee4576adf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle-union1.C
@@ -0,0 +1,10 @@
+// PR c++/104847
+// { dg-do compile { target c++11 } }
+
+struct S { int i; };
+union U { S k; };
+template <class T, class... Ts> T sink(T&&, Ts&&...);
+template <class T>
+decltype(sink(U{1},T())) f(T) { return U{1}; }
+int main() { f(3); }
+// { dg-final { scan-assembler "_Z1fIiEDTcl4sinktl1ULi1EEcvT__EEES1_" } }
base-commit: bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717
prerequisite-patch-id: 09e711b54e7911a4a04bd7808abc1b73ae4482ba
prerequisite-patch-id: 566cf0772894d0c6a842b2e0ca62eb1d5ae8ad33
--
2.27.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-28 13:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 13:32 [pushed] c++: mangling union{1} in template [PR104847] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).