From patchwork Thu Sep 19 13:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1164610 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-509272-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="L7LvHYz9"; 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 46YyNl0MjCz9s4Y for ; Thu, 19 Sep 2019 23:28:54 +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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=Re7mGtIsPvLvx626Lc22HmRPuRqQiQVhVXqNv5gX7Ua032s58s nBoFFeh8yFJMhoPVRVPh53eBviOe7Sd4X71WJn3cjHwfvfrcE8a4gEjlRU+BNnTl jv0IS6oxwrH5wedVnGp8kX8mnnleva+liw99RXrQ3KoEtr3BolEgAUjNM= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=SjghqsEHQyfIHWI+v26jU208zR4=; b=L7LvHYz9+jyQtXyr0Dfm FbuqPdJOLAOfdqTDiU8wQVFJVjVzoJLXTOFAhP3RFxRGGMY5NJ531gFGKyz4xMxZ Ip6xFk1by3Defs17HfVTfziH+rJ4yl08IWOTCMvj2+7gmSPSyZy+NYOmHh3AuhwW w3v20Xwz0sR9zbL/LIOrmFc= Received: (qmail 848 invoked by alias); 19 Sep 2019 13:28:23 -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 789 invoked by uid 89); 19 Sep 2019 13:28:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Nkind, nkind, Bob, sk:N_Expli X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 13:28:21 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4C35856021; Thu, 19 Sep 2019 09:28:19 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LLdV1qkxiHkR; Thu, 19 Sep 2019 09:28:19 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 33C095601C; Thu, 19 Sep 2019 09:28:19 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 3291E6B4; Thu, 19 Sep 2019 09:28:19 -0400 (EDT) Date: Thu, 19 Sep 2019 09:28:19 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Infinite loop with concatenation and aspect Message-ID: <20190919132819.GA41695@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This patch fixes a bug where an array object initialized with a concatenation, and that has an aspect_specification for Alignment, causes the compiler goes into an infinite loop. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-19 Bob Duff gcc/ada/ * exp_ch3.adb (Rewrite_As_Renaming): Return False if there are any aspect specifications, because otherwise Insert_Actions blows up. gcc/testsuite/ * gnat.dg/concat3.adb: New testcase. --- gcc/ada/exp_ch3.adb +++ gcc/ada/exp_ch3.adb @@ -6318,7 +6318,8 @@ package body Exp_Ch3 is ------------------------- function Rewrite_As_Renaming return Boolean is - begin + Result : constant Boolean := + -- If the object declaration appears in the form -- Obj : Ctrl_Typ := Func (...); @@ -6336,12 +6337,12 @@ package body Exp_Ch3 is -- This part is disabled for now, because it breaks GPS builds - return (False -- ??? - and then Nkind (Expr_Q) = N_Explicit_Dereference - and then not Comes_From_Source (Expr_Q) - and then Nkind (Original_Node (Expr_Q)) = N_Function_Call - and then Nkind (Object_Definition (N)) in N_Has_Entity - and then (Needs_Finalization (Entity (Object_Definition (N))))) + (False -- ??? + and then Nkind (Expr_Q) = N_Explicit_Dereference + and then not Comes_From_Source (Expr_Q) + and then Nkind (Original_Node (Expr_Q)) = N_Function_Call + and then Nkind (Object_Definition (N)) in N_Has_Entity + and then (Needs_Finalization (Entity (Object_Definition (N))))) -- If the initializing expression is for a variable with attribute -- OK_To_Rename set, then transform: @@ -6362,6 +6363,14 @@ package body Exp_Ch3 is and then Ekind (Entity (Expr_Q)) = E_Variable and then OK_To_Rename (Entity (Expr_Q)) and then Is_Entity_Name (Obj_Def)); + begin + -- Return False if there are any aspect specifications, because + -- otherwise we duplicate that corresponding implicit attribute + -- definition, and call Insert_Action, which has no place to insert + -- the attribute definition. The attribute definition is stored in + -- Aspect_Rep_Item, which is not a list. + + return Result and then No (Aspect_Specifications (N)); end Rewrite_As_Renaming; -- Local variables --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/concat3.adb @@ -0,0 +1,14 @@ +-- { dg-do run } +-- { dg-options "-g -O0 -gnata" } + +procedure Concat3 is + procedure Show_Bug (S : in String) + is + Str : constant String := S & "-" with Alignment => 4; + begin + null; + end Show_Bug; + +begin + Show_Bug ("BUG"); +end Concat3; \ No newline at end of file