public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7849] c++: mangling union{1} in template [PR104847]
@ 2022-03-28 13:37 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-03-28 13:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:71e1db540c01a13b01fae054c92878a79252b471

commit r12-7849-g71e1db540c01a13b01fae054c92878a79252b471
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Mar 26 20:10:19 2022 -0400

    c++: mangling union{1} in template [PR104847]
    
    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.
    
            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.

Diff:
---
 gcc/cp/mangle.cc                         |  2 +-
 gcc/testsuite/g++.dg/abi/mangle-union1.C | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

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_" } }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-28 13:37 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:37 [gcc r12-7849] 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).