From patchwork Thu Dec 2 16:28:58 2021 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: 48410 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA7ED385BF86 for ; Thu, 2 Dec 2021 16:46:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA7ED385BF86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638463583; bh=iHXhuIgjAnYYxU5bHd/Qf/ZuWsIbhtqSNHbIx5Bmt/o=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QSiNtaRRF4cHc/HIW6stdBcHsY3X2OzoF5do27a4OlfObaOiaaaEJRh/ZQcVYR8XV fy2yqgr1/D/XfAfkhwj0MFwF7z48Zej4hgoyEt1ZB8T2c84Wt41G+WSedWhKTKT47b knabCwOGatCwNYvlpf7piVwFH3zWTPmmdJN4MYbs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 8DFBF385AC36 for ; Thu, 2 Dec 2021 16:29:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DFBF385AC36 Received: by mail-wm1-x32c.google.com with SMTP id i12so190322wmq.4 for ; Thu, 02 Dec 2021 08:29:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=iHXhuIgjAnYYxU5bHd/Qf/ZuWsIbhtqSNHbIx5Bmt/o=; b=kQW/0rpmVJO3qSVt1CzVxOtOmf7rLsqN6EbbHGQ8aTHD52WsItkzZAfcK/aEVkQRsy QejjfStgq4FaV7p0+gEyVClhqeOGrhWMp5+tLC83/7uCYlMklfqB5fTlgni8yryBHJhx 5cSAVbVtDfMqz9+ktC1Me4PRLAn2gH3A4NtG0tSSmnJbGnrZf1axovGnn6BsMxPdNBQ3 G02dhzsNkThM31j0y5ZM6+nNFquWjwH1L3718Lf2aSgbfW28da8bd8qAujw3Ih9g2GmS eprPqAGj235d0WT2YIPHArK8d0b+M5YyGrA7j7I+fsvqihBcuMoJkFvQ8r1672Qkie8F q+9g== X-Gm-Message-State: AOAM531x/UDMfCOzvoCAPj7Qh6AuBRVGv2I3axR64JM5tt5NQljIOwjG Oo/dSZF8B0z0Z0IQejs93tqkPjjT2rsGvQ== X-Google-Smtp-Source: ABdhPJxBqfacA3h2vhrMzqVJIpmoRHfgseffO0cLAYVGRcnWrqqqjf+2Y9bqU6AWDOJLR50tqvAurQ== X-Received: by 2002:a1c:5414:: with SMTP id i20mr7692768wmb.88.1638462539668; Thu, 02 Dec 2021 08:28:59 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id p12sm360091wrr.10.2021.12.02.08.28.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 08:28:58 -0800 (PST) Date: Thu, 2 Dec 2021 16:28:58 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Cleanups related to expansion of dispatching primitives Message-ID: <20211202162858.GA2159594@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Assorted cleanups related to expansion of dispatching primitives on derived types for GNATprove; semantics of the compiler is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/standard_and_implementation_defined_restrictions.rst (No_Dispatching_Calls): Fix whitespace in example code. * gnat_rm.texi: Regenerate. * exp_ch13.adb (Expand_N_Freeze_Entity): Replace low-level membership test with a high-level wrapper. * exp_ch3.adb (Expand_Freeze_Record_Type): Remove unnecessary initialization of list of wrapper declarations and unnecessary guard for list of their bodies (if no bodies are created then Append_Freeze_Actions is a no-op). diff --git a/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst b/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst --- a/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst +++ b/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst @@ -239,7 +239,7 @@ The following example indicates constructs that violate this restriction. with Pkg; use Pkg; procedure Example is procedure Test (O : T'Class) is - N : Natural := O'Size;-- Error: Dispatching call + N : Natural := O'Size; -- Error: Dispatching call C : T'Class := O; -- Error: implicit Dispatching Call begin if O in DT'Class then -- OK : Membership test diff --git a/gcc/ada/exp_ch13.adb b/gcc/ada/exp_ch13.adb --- a/gcc/ada/exp_ch13.adb +++ b/gcc/ada/exp_ch13.adb @@ -491,7 +491,7 @@ package body Exp_Ch13 is -- a constrained type extension with inherited discriminants. if Is_Type (E_Scope) - and then Ekind (E_Scope) not in Concurrent_Kind + and then not Is_Concurrent_Type (E_Scope) then E_Scope := Scope (E_Scope); diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -5495,7 +5495,7 @@ package body Exp_Ch3 is Comp_Typ : Entity_Id; Predef_List : List_Id; - Wrapper_Decl_List : List_Id := No_List; + Wrapper_Decl_List : List_Id; Wrapper_Body_List : List_Id := No_List; Renamed_Eq : Node_Id := Empty; @@ -5906,9 +5906,7 @@ package body Exp_Ch3 is -- Ada 2005 (AI-391): If any wrappers were created for nonoverridden -- inherited functions, then add their bodies to the freeze actions. - if Present (Wrapper_Body_List) then - Append_Freeze_Actions (Typ, Wrapper_Body_List); - end if; + Append_Freeze_Actions (Typ, Wrapper_Body_List); -- Create extra formals for the primitive operations of the type. -- This must be done before analyzing the body of the initialization diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -12621,7 +12621,7 @@ end Pkg; with Pkg; use Pkg; procedure Example is procedure Test (O : T'Class) is - N : Natural := O'Size;-- Error: Dispatching call + N : Natural := O'Size; -- Error: Dispatching call C : T'Class := O; -- Error: implicit Dispatching Call begin if O in DT'Class then -- OK : Membership test