From patchwork Thu Apr 11 21:15:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1084287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-499140-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="RZMCH5qS"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44gDNT71LTz9s47 for ; Fri, 12 Apr 2019 07:16:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=NqXGFZyunnWRjrQ0nI2QWDkqG6OaKrEVTBD3AxmDW/jhv1 0+Th0mDNUIQSt0Cm6UV8a/l8nk4KXq4r8sdx8RcgJT+GADvjiJSj/8jFs4B49oF7 iVtqkUKWffWiVPBnhtiWPhW2dJrFEaJwTCfdpV3murSoar37SRWq1a1fSDwQQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=7P7oliGs42xQhIkbnwMJgTjzPu8=; b=RZMCH5qSnW+c8q8ivNs3 WrX1qVOuneah3WosX1clyWb4fZn3RAdWdmy1EhIHGWiEQLKPYONzcqpZQl8E2YnV DeONDAayHpDXcv0PoajrxeZ95faXOLd9C7baqxrwfHWQCkuwEP6zEzVbuHSoYtHT F/ODCHJHxOwgrta/T+OhTrM= Received: (qmail 14626 invoked by alias); 11 Apr 2019 21:16:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14440 invoked by uid 89); 11 Apr 2019 21:15:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1861 X-HELO: mail-qt1-f179.google.com Received: from mail-qt1-f179.google.com (HELO mail-qt1-f179.google.com) (209.85.160.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Apr 2019 21:15:53 +0000 Received: by mail-qt1-f179.google.com with SMTP id z16so8907141qtn.4 for ; Thu, 11 Apr 2019 14:15:37 -0700 (PDT) MIME-Version: 1.0 From: Iain Buclaw Date: Thu, 11 Apr 2019 23:15:24 +0200 Message-ID: Subject: [PATCH, d] Committed merge with upstream dmd To: gcc-patches X-IsSubscribed: yes Hi, This patch merges the D front-end implementation with dmd upstream d7ed327ed. Backports fix for an ICE that occurred when accessing empty array in CTFE. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r270294. diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 31ea106965b..800be95e4e6 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -5dd3eccc3b0758346f77bee3cdc3f6bd15de339b +d7ed327edb0b01ad56e7e73e77b3401cd565675e The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c index 777f89cf186..40f3e77cbc5 100644 --- a/gcc/d/dmd/dinterpret.c +++ b/gcc/d/dmd/dinterpret.c @@ -6272,11 +6272,14 @@ Expression *scrubReturnValue(Loc loc, Expression *e) /* Returns: true if e is void, * or is an array literal or struct literal of void elements. */ -static bool isVoid(Expression *e) +static bool isVoid(Expression *e, bool checkArray = false) { if (e->op == TOKvoid) return true; + if (checkArray && e->type->ty != Tsarray) + return false; + if (e->op == TOKarrayliteral) return isEntirelyVoid(((ArrayLiteralExp *)e)->elements); @@ -6314,7 +6317,7 @@ Expression *scrubArray(Loc loc, Expressions *elems, bool structlit) // A struct .init may contain void members. // Static array members are a weird special case (bug 10994). - if (structlit && isVoid(e)) + if (structlit && isVoid(e, true)) { e = NULL; } diff --git a/gcc/testsuite/gdc.test/compilable/test19778.d b/gcc/testsuite/gdc.test/compilable/test19778.d new file mode 100644 index 00000000000..87905fae6a0 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test19778.d @@ -0,0 +1,6 @@ +struct S +{ + int[] data; +} +immutable X = S([]); +enum len = X.data.length;