public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7738] d: Fix internal compiler error: in build_complex, at tree.c:2358 Date: Mon, 21 Mar 2022 19:56:51 +0000 (GMT) [thread overview] Message-ID: <20220321195651.17F8C385E83F@sourceware.org> (raw) https://gcc.gnu.org/g:1dd51373a82408361068e130a84caa888ef0d2b3 commit r12-7738-g1dd51373a82408361068e130a84caa888ef0d2b3 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Mon Mar 21 19:47:50 2022 +0100 d: Fix internal compiler error: in build_complex, at tree.c:2358 The conversion from the special _Complex enum to native complex used build_complex, however the input value isn't necessarily a literal. PR d/105004 gcc/d/ChangeLog: * d-codegen.cc (build_struct_literal): Use complex_expr to build complex expressions from __c_complex types. gcc/testsuite/ChangeLog: * gdc.dg/pr105004.d: New test. Diff: --- gcc/d/d-codegen.cc | 2 +- gcc/testsuite/gdc.dg/pr105004.d | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 3e54d3bffd0..3206edd17e8 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -1161,7 +1161,7 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init) if (COMPLEX_FLOAT_TYPE_P (type)) { gcc_assert (vec_safe_length (init) == 2); - return build_complex (type, (*init)[0].value, (*init)[1].value); + return complex_expr (type, (*init)[0].value, (*init)[1].value); } vec <constructor_elt, va_gc> *ve = NULL; diff --git a/gcc/testsuite/gdc.dg/pr105004.d b/gcc/testsuite/gdc.dg/pr105004.d new file mode 100644 index 00000000000..60b3c3f635e --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr105004.d @@ -0,0 +1,14 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105004 +// { dg-do compile } + +private struct _Complex(T) +{ + T re; + T im; +} +enum __c_complex_float : _Complex!float; + +__c_complex_float pr105004(float re, float im) +{ + return typeof(return)(re, im); +}
reply other threads:[~2022-03-21 19:56 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=20220321195651.17F8C385E83F@sourceware.org \ --to=ibuclaw@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).