From patchwork Mon Jul 22 14:02:13 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: 1134941 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-505434-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="H6rWHm8h"; 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 45sjzB5nKJz9sBZ for ; Tue, 23 Jul 2019 00:04:38 +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=qhdevs8aZlrE/PxdYdRd/EQA0qHgLXX6rInStRD5tNF2A/wqv9 iyrMJf7hUPMENGPQHVtAPBFKy19851AmhVu0cuvLBSss0jwZwgA1aFAjRKH7mU/3 rJb0FRsHutYbT2WQPiiIEwYrlVOuAc9ob2FHCGFBzH0zrKq5zj7rCTsZk= 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=d/w/CT/SNuTit33PWQdJp+70890=; b=H6rWHm8hJlvf9DlSNHTa CwykZcgk6IVaB2uIWQk/XkQ4I1FkSqQo/5qhrWfHM1s1PO6ZDWelOc8+gDvh7G6C /hJCUbDNjNVKDQZBIopkAQ7wvr8j2uD6Y4KfEUeFmbfLMV3f+EVNTypvus5laUf4 7/3jPw38iPBj7db7mo0RyUU= Received: (qmail 91109 invoked by alias); 22 Jul 2019 14:02:21 -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 90426 invoked by uid 89); 22 Jul 2019 14:02:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=entities 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, 22 Jul 2019 14:02:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9ECCF116ABD; Mon, 22 Jul 2019 10:02:13 -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 HOaw2nxpklP5; Mon, 22 Jul 2019 10:02:13 -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 8C922116A8C; Mon, 22 Jul 2019 10:02:13 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 8BA826A7; Mon, 22 Jul 2019 10:02:13 -0400 (EDT) Date: Mon, 22 Jul 2019 10:02:13 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Remove obsolete Is_For_Access_Subtype machinery Message-ID: <20190722140211.GA60946@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This change removes the Is_For_Access_Subtype machinery from the compiler. This machinery was devised a long time ago to deal with a peculiarity of the freezing for access-to-record subtypes but has been degenerate for quite some time now and does not seem to serve any useful purpose at this point. Morever it has an annoying side effect whereby it causes Underlying_Type to return the (unconstrained) base record type when invoked on the designated record subtype, which is very problematic for GNATprove. There should be no functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-07-22 Eric Botcazou gcc/ada/ * einfo.ads (Is_For_Access_Subtype): Delete. (Set_Is_For_Access_Subtype): Likewise. * einfo.adb (Is_For_Access_Subtype): Likewise. (Set_Is_For_Access_Subtype): Likewise. (Write_Entity_Flags): Do not write Is_For_Access_Subtype. * exp_ch4.adb (Expand_N_Selected_Component): Do not deal with it. * exp_spark.adb (Expand_SPARK_N_Selected_Component): Likewise. * sem_ch4.adb (Analyze_Explicit_Dereference): Likewise. * sem_ch3.adb (Build_Discriminated_Subtype): Do not build a special private subtype for access-to-record subtypes. --- gcc/ada/einfo.adb +++ gcc/ada/einfo.adb @@ -421,7 +421,6 @@ package body Einfo is -- Never_Set_In_Source Flag115 -- Is_Visible_Lib_Unit Flag116 -- Is_Unchecked_Union Flag117 - -- Is_For_Access_Subtype Flag118 -- Has_Convention_Pragma Flag119 -- Has_Primitive_Operations Flag120 @@ -2303,12 +2302,6 @@ package body Einfo is return Flag70 (Id); end Is_First_Subtype; - function Is_For_Access_Subtype (Id : E) return B is - begin - pragma Assert (Ekind_In (Id, E_Record_Subtype, E_Private_Subtype)); - return Flag118 (Id); - end Is_For_Access_Subtype; - function Is_Formal_Subprogram (Id : E) return B is begin return Flag111 (Id); @@ -5526,12 +5519,6 @@ package body Einfo is Set_Flag70 (Id, V); end Set_Is_First_Subtype; - procedure Set_Is_For_Access_Subtype (Id : E; V : B := True) is - begin - pragma Assert (Ekind_In (Id, E_Record_Subtype, E_Private_Subtype)); - Set_Flag118 (Id, V); - end Set_Is_For_Access_Subtype; - procedure Set_Is_Formal_Subprogram (Id : E; V : B := True) is begin Set_Flag111 (Id, V); @@ -9826,7 +9813,6 @@ package body Einfo is W ("Is_Exported", Flag99 (Id)); W ("Is_Finalized_Transient", Flag252 (Id)); W ("Is_First_Subtype", Flag70 (Id)); - W ("Is_For_Access_Subtype", Flag118 (Id)); W ("Is_Formal_Subprogram", Flag111 (Id)); W ("Is_Frozen", Flag4 (Id)); W ("Is_Generic_Actual_Subprogram", Flag274 (Id)); --- gcc/ada/einfo.ads +++ gcc/ada/einfo.ads @@ -2608,12 +2608,6 @@ package Einfo is -- Is_Formal_Subprogram (Flag111) -- Defined in all entities. Set for generic formal subprograms. --- Is_For_Access_Subtype (Flag118) --- Defined in E_Private_Subtype and E_Record_Subtype entities. Means the --- sole purpose of the type is to be designated by an Access_Subtype and --- hence should not be expanded into components because the type may not --- have been found or frozen yet. - -- Is_Frozen (Flag4) -- Defined in all type and subtype entities. Set if type or subtype has -- been frozen. @@ -6458,7 +6452,6 @@ package Einfo is -- Stored_Constraint (Elist23) -- Has_Completion (Flag26) -- Is_Controlled_Active (Flag42) (base type only) - -- Is_For_Access_Subtype (Flag118) (subtype only) -- (plus type attributes) -- E_Procedure @@ -7311,7 +7304,6 @@ package Einfo is function Is_Exported (Id : E) return B; function Is_Finalized_Transient (Id : E) return B; function Is_First_Subtype (Id : E) return B; - function Is_For_Access_Subtype (Id : E) return B; function Is_Frozen (Id : E) return B; function Is_Generic_Instance (Id : E) return B; function Is_Hidden (Id : E) return B; @@ -8012,7 +8004,6 @@ package Einfo is procedure Set_Is_Exported (Id : E; V : B := True); procedure Set_Is_Finalized_Transient (Id : E; V : B := True); procedure Set_Is_First_Subtype (Id : E; V : B := True); - procedure Set_Is_For_Access_Subtype (Id : E; V : B := True); procedure Set_Is_Formal_Subprogram (Id : E; V : B := True); procedure Set_Is_Frozen (Id : E; V : B := True); procedure Set_Is_Generic_Actual_Subprogram (Id : E; V : B := True); @@ -8859,7 +8850,6 @@ package Einfo is pragma Inline (Is_First_Subtype); pragma Inline (Is_Fixed_Point_Type); pragma Inline (Is_Floating_Point_Type); - pragma Inline (Is_For_Access_Subtype); pragma Inline (Is_Formal); pragma Inline (Is_Formal_Object); pragma Inline (Is_Formal_Subprogram); @@ -9376,7 +9366,6 @@ package Einfo is pragma Inline (Set_Is_Exported); pragma Inline (Set_Is_Finalized_Transient); pragma Inline (Set_Is_First_Subtype); - pragma Inline (Set_Is_For_Access_Subtype); pragma Inline (Set_Is_Formal_Subprogram); pragma Inline (Set_Is_Frozen); pragma Inline (Set_Is_Generic_Actual_Subprogram); --- gcc/ada/exp_ch4.adb +++ gcc/ada/exp_ch4.adb @@ -10330,12 +10330,6 @@ package body Exp_Ch4 is Insert_Explicit_Dereference (P); Analyze_And_Resolve (P, Designated_Type (Ptyp)); - if Ekind (Etype (P)) = E_Private_Subtype - and then Is_For_Access_Subtype (Etype (P)) - then - Set_Etype (P, Base_Type (Etype (P))); - end if; - Ptyp := Etype (P); end if; --- gcc/ada/exp_spark.adb +++ gcc/ada/exp_spark.adb @@ -522,12 +522,6 @@ package body Exp_SPARK is Insert_Explicit_Dereference (Pref); Analyze_And_Resolve (Pref, Designated_Type (Typ)); - - if Ekind (Etype (Pref)) = E_Private_Subtype - and then Is_For_Access_Subtype (Etype (Pref)) - then - Set_Etype (Pref, Base_Type (Etype (Pref))); - end if; end if; end Expand_SPARK_N_Selected_Component; --- gcc/ada/sem_ch3.adb +++ gcc/ada/sem_ch3.adb @@ -221,9 +221,7 @@ package body Sem_Ch3 is -- T has discriminants but there are no discriminant constraints). The -- Related_Nod is the same as Decl_Node in Create_Constrained_Components. -- The For_Access says whether or not this subtype is really constraining - -- an access type. That is its sole purpose is the designated type of an - -- access type -- in which case a Private_Subtype Is_For_Access_Subtype - -- is built to avoid freezing T when the access subtype is frozen. + -- an access type. function Build_Scalar_Bound (Bound : Node_Id; @@ -10236,12 +10234,7 @@ package body Sem_Ch3 is begin if Ekind (T) = E_Record_Type then - if For_Access then - Set_Ekind (Def_Id, E_Private_Subtype); - Set_Is_For_Access_Subtype (Def_Id, True); - else - Set_Ekind (Def_Id, E_Record_Subtype); - end if; + Set_Ekind (Def_Id, E_Record_Subtype); -- Inherit preelaboration flag from base, for types for which it -- may have been set: records, private types, protected types. @@ -10372,7 +10365,7 @@ package body Sem_Ch3 is then Create_Constrained_Components (Def_Id, Related_Nod, T, Elist); - elsif not For_Access then + else Set_Cloned_Subtype (Def_Id, T); end if; end if; --- gcc/ada/sem_ch4.adb +++ gcc/ada/sem_ch4.adb @@ -2101,21 +2101,12 @@ package body Sem_Ch4 is if not Is_Overloaded (P) then if Is_Access_Type (Etype (P)) then - -- Set the Etype. We need to go through Is_For_Access_Subtypes to - -- avoid other problems caused by the Private_Subtype and it is - -- safe to go to the Base_Type because this is the same as - -- converting the access value to its Base_Type. + -- Set the Etype declare - DT : Entity_Id := Designated_Type (Etype (P)); + DT : constant Entity_Id := Designated_Type (Etype (P)); begin - if Ekind (DT) = E_Private_Subtype - and then Is_For_Access_Subtype (DT) - then - DT := Base_Type (DT); - end if; - -- An explicit dereference is a legal occurrence of an -- incomplete type imported through a limited_with clause, if -- the full view is visible, or if we are within an instance