From patchwork Tue Sep 5 08:22:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 809992 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-461455-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="F/Xs15VM"; 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 3xmfpg3sbWz9s9Y for ; Tue, 5 Sep 2017 18:22:34 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=KAQn+zeDDLlu2NiT iDZRhj30Wcwl3v9vearE4QL2fwuAHChfEh00uFPkNh3yZsltQHKeAuFsDQxrbrP0 y2211fRdL4n2/Gd+1FwB7SQUZMgff78BY5h0uT8TvqSbHFFrwInrXaR0lqnSx0co FU0LNXuUSb3yTX7q+VkfbP7BIAY= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=kI2ck+nbeDB8S9TMXZ/hSf IuRRg=; b=F/Xs15VMmbvfBJocDvmYLoV8eHyZbnkemjqZMkrwZGX+rBcm6Kp/1a XOOQ7obb5LyXNGJdeEu+cT66mDbPhm5B7HN6BfatLQ64AKnCXt9Gq+okXrapPrKd OQjz012MVtxhlXdvXtTYCrKL3tVE+gdXset4001reQYcUPGZrooL8= Received: (qmail 26446 invoked by alias); 5 Sep 2017 08:22:25 -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 26312 invoked by uid 89); 5 Sep 2017 08:22:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Sep 2017 08:22:06 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1B6A8822E8 for ; Tue, 5 Sep 2017 10:22:04 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ncgzs0bj9n-A for ; Tue, 5 Sep 2017 10:22:04 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id D884982293 for ; Tue, 5 Sep 2017 10:22:03 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on multi-dimensional array Date: Tue, 05 Sep 2017 10:22:02 +0200 Message-ID: <8455722.vByhrAPZx7@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This is a regression present on the mainline, 7 and 6 branches, in the form of an ICE during tree-sra, which is confused by an unconstrained array type. Tested on x86_64-suse-linux, applied on mainline, 7 and 6 branches. 2017-09-05 Eric Botcazou * gcc-interface/trans.c (pos_to_constructor): Skip conversions to an unconstrained array type. 2017-09-05 Eric Botcazou * testsuite/gnat.dg/array29.ad[sb]: New test. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 251553) +++ gcc-interface/trans.c (working copy) @@ -9826,7 +9826,14 @@ pos_to_constructor (Node_Id gnat_expr, t gnat_component_type); else { - gnu_expr = gnat_to_gnu (gnat_expr); + /* If the expression is a conversion to an unconstrained array type, + skip it to avoid spilling to memory. */ + if (Nkind (gnat_expr) == N_Type_Conversion + && Is_Array_Type (Etype (gnat_expr)) + && !Is_Constrained (Etype (gnat_expr))) + gnu_expr = gnat_to_gnu (Expression (gnat_expr)); + else + gnu_expr = gnat_to_gnu (gnat_expr); /* Before assigning the element to the array, make sure it is in range. */