From patchwork Sun Nov 13 18:13:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 81965 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp689778qge; Sun, 13 Nov 2016 10:13:33 -0800 (PST) X-Received: by 10.99.108.8 with SMTP id h8mr41427730pgc.93.1479060813064; Sun, 13 Nov 2016 10:13:33 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e69si19226521pfk.231.2016.11.13.10.13.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2016 10:13:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441254-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441254-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441254-patch=linaro.org@gcc.gnu.org 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=eNQRsG3tHlmi2kTI RAhBiK5DOINgrVd8ZCvi71qu98IluEXoHrCp6UBD/QRJ+6n6Fe2pyZ/mSC3UmTVj iCQKsnZDT0ZhMptKEz/UmmYN4nPUA/w0gYUObxzGRt73vr6buHmPy9b2b0u8cpX2 rsBjMlx/1GQERJvBi6xgBQobS3M= 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=+3JOHNLaBh1Z4amBMaEZz3 7Q0f4=; b=Tn8djjN4epR91i0HqZsNqlBZlsuZZuQWaKtCmx88pXG16G5/ynJAvn DUX/mWfKnmIdXfbMQHyTZAN/km9LOj2076fg8n/jspM0bGITDp0+KH8RJFyc3PGF 43JcgTjklV4m9QdZ41gdWcaaukZRVDhgpdDFeeMzuSg38Gwfuekys= Received: (qmail 42343 invoked by alias); 13 Nov 2016 18:13:17 -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 42327 invoked by uid 89); 13 Nov 2016 18:13:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2298, UD:all, 25866, 2586, 6 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; Sun, 13 Nov 2016 18:13:06 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 19F24812EF for ; Sun, 13 Nov 2016 19:13:04 +0100 (CET) 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 gznTLCfSPTxb for ; Sun, 13 Nov 2016 19:13:04 +0100 (CET) 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 E4459812EE for ; Sun, 13 Nov 2016 19:13:03 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on double renaming with chain of access types Date: Sun, 13 Nov 2016 19:13:03 +0100 Message-ID: <2936922.FcVY0T6Fgs@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-48-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This is a regression present on the mainline and 6 branch: the compiler ICEs in the gimplifier on a double renaming with a chain of access types because there is a orphaned PLACEHOLDER_EXPR. Tested on x86_64-suse-linux, applied on the mainline and 6 branch. 2016-11-13 Eric Botcazou * gcc-interface/utils2.c (gnat_protect_expr): Also protect only the address if the expression is the component of a dereference. Do not use a reference type for the final temporary reference. 2016-11-13 Eric Botcazou * gnat.dg/renaming11.ad[sb]: New test. -- Eric Botcazou Index: gcc-interface/utils2.c =================================================================== --- gcc-interface/utils2.c (revision 242334) +++ gcc-interface/utils2.c (working copy) @@ -2586,6 +2586,12 @@ gnat_protect_expr (tree exp) return t; } + /* Likewise if we're indirectly referencing part of something. */ + if (code == COMPONENT_REF + && TREE_CODE (TREE_OPERAND (exp, 0)) == INDIRECT_REF) + return build3 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0)), + TREE_OPERAND (exp, 1), NULL_TREE); + /* If this is a COMPONENT_REF of a fat pointer, save the entire fat pointer. This may be more efficient, but will also allow us to more easily find the match for the PLACEHOLDER_EXPR. */ @@ -2605,9 +2611,7 @@ gnat_protect_expr (tree exp) /* Otherwise reference, protect the address and dereference. */ return build_unary_op (INDIRECT_REF, type, - save_expr (build_unary_op (ADDR_EXPR, - build_reference_type (type), - exp))); + save_expr (build_unary_op (ADDR_EXPR, NULL_TREE, exp))); } /* This is equivalent to stabilize_reference_1 in tree.c but we take an extra