From patchwork Mon Jun 11 09:23:00 2018 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: 927556 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-479438-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="VoeZL1Te"; 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 4146y83LvQz9ryk for ; Mon, 11 Jun 2018 19:23:27 +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=NRxqGF8XeS64Unrr99I6qyZ5vbP5AvNzTscutho5PQHaN2pfJo cMHXMR2Udu6Ur3dXDYVVhqvQY/DM98CLfP1LPf2AKpKopT3r9s/moQqp5m7n3Dwd X1jpuhZManXbrjAkkTCYg8dpDgssOg+9PGCMC8V9lv9VC7G3axDWABgwg= 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=grLZ1VR4aCaMqoYsocNNUQ1x39A=; b=VoeZL1TesMdH7U5c2Uyt u7E71gqir9Uq8AqKECBXrFBzlfq6WFKYSnbibfc/2MqcSca9ps6r5VmAZe3sQfBq OYIzIM/MV0k9eLmN4+drfvKlYlFUFRsu8X9y0GEFROoqLKd8XAKqN8AqRyjm2GLD O244RnQjbL37L+Go2Ahy0Kc= Received: (qmail 27781 invoked by alias); 11 Jun 2018 09:23:04 -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 27679 invoked by uid 89); 11 Jun 2018 09:23:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=beta, family 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; Mon, 11 Jun 2018 09:23:01 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 56EE8560ED; Mon, 11 Jun 2018 05:23:00 -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 LncM1+MoEqoz; Mon, 11 Jun 2018 05:23:00 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 44A7B560EC; Mon, 11 Jun 2018 05:23:00 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 43B1B54C; Mon, 11 Jun 2018 05:23:00 -0400 (EDT) Date: Mon, 11 Jun 2018 05:23:00 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] Crash on protected type entry family Message-ID: <20180611092300.GA134983@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes The compiler may blow up compiling the body of a protected type that has a family entry whose entry index specification contains a call to a function. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-06-11 Javier Miranda gcc/ada/ * exp_ch9.adb (Expand_N_Protected_Body): Add missing handling of N_Call_Marker nodes. gcc/testsuite/ * gnat.dg/prot4.adb: New testcase. --- gcc/ada/exp_ch9.adb +++ gcc/ada/exp_ch9.adb @@ -8653,8 +8653,11 @@ package body Exp_Ch9 is when N_Implicit_Label_Declaration => null; - when N_Itype_Reference => - Insert_After (Current_Node, New_Copy (Op_Body)); + when N_Call_Marker | + N_Itype_Reference => + New_Op_Body := New_Copy (Op_Body); + Insert_After (Current_Node, New_Op_Body); + Current_Node := New_Op_Body; when N_Freeze_Entity => New_Op_Body := New_Copy (Op_Body); --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/prot4.adb @@ -0,0 +1,28 @@ +-- { dg-do compile } + +procedure Prot4 is + type App_Priority is (Low, Medium, High); + + function Alpha return App_Priority is + begin + return Low; + end Alpha; + + function Beta return App_Priority is + begin + return High; + end Beta; + + protected Hold is + entry D7 (App_Priority range Alpha .. Beta); + end Hold; + + protected body Hold is + entry D7 (for AP in App_Priority range Alpha .. Beta) when True is + begin + null; + end D7; + end Hold; +begin + null; +end;