From patchwork Mon Mar 21 19:58:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1607883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=gn6fewaC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KMlpW0z3hz9s0r for ; Tue, 22 Mar 2022 07:00:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7AF63898C73 for ; Mon, 21 Mar 2022 20:00:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7AF63898C73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1647892816; bh=GJFhzdC3kKH4Teah6CdjfR8zLQcvBDxg0aQ7Yjb+va4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gn6fewaCBBNJaJbyZ2VKQ0sbzMnQEqxv5hQ1jdG4yWR/3BBVbDHSg4MZSZTRoxWTs xQ+oG9jixpVC20k9j7nQCopH1ejdZEVc32KMs30hLZ8+5UKIZJ/Xa2dNAa6NxpejLD GsxiyGOB7u2wh09UlpNCMMcRmuXopnCKBkFqx0z4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id CB265386EC0D for ; Mon, 21 Mar 2022 19:58:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB265386EC0D Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4KMlmQ4Rx6z9sTS; Mon, 21 Mar 2022 20:58:30 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Fix internal compiler error: in build_complex, at tree.c:2358 Date: Mon, 21 Mar 2022 20:58:21 +0100 Message-Id: <20220321195821.1646187-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch fixes an ICE in the D front-end when constructing a complex object from a struct literal typed as enum __c_complex_float. The conversion from the special _Complex enum to native complex used build_complex, however the input value isn't necessarily a literal. Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, committed to mainline, and backported to the releases/gcc-11 branch. Regards, Iain. --- 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. --- gcc/d/d-codegen.cc | 2 +- gcc/testsuite/gdc.dg/pr105004.d | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gdc.dg/pr105004.d 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 *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 *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); +}