public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7849] c++: mangling union{1} in template [PR104847] Date: Mon, 28 Mar 2022 13:37:12 +0000 (GMT) [thread overview] Message-ID: <20220328133712.8D019385782D@sourceware.org> (raw) 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_" } }
reply other threads:[~2022-03-28 13:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220328133712.8D019385782D@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).