From patchwork Mon May 29 08:29:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 100176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1368326vqr; Mon, 29 May 2023 01:50:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qlaLANnhSjPQwunV7JWOBcnSrUMOsI89fOjbkgeIKZ8Zi057kLHUcJ8+LWtF5IvDTI3fB X-Received: by 2002:a17:907:80e:b0:96f:5747:a0de with SMTP id wv14-20020a170907080e00b0096f5747a0demr9780933ejb.6.1685350222758; Mon, 29 May 2023 01:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685350222; cv=none; d=google.com; s=arc-20160816; b=Dt35xepHIdieekuqhod54VbdALsPAGXX/ImJ+UwjvXezM/Z9yKB95kUEs/QFpwQSAm 6+y6Yt35sp1TS0ZgzMS1y/X3xtqXRBPjBX293jTu6p0w7bz9dIHNtz9XW7mfNsavLZvG ZTU8WGlmUJWiFkgFHwJg9hTefc6znZirrpNyLVoH/1NCHcv/Ps9SEIKSVmCHVVxtrmFH h2q6l2DryW/fwQuvMMVAosdSR0ER73Ay2tGUrEDqMy8FJX5Wti7ogQZT5H5lQs+U/uwp xKjZNBsEqy7Y0UEkEfepDSMVCoXREh9tpF8HiskpHCycWR7aiE9akF749TdrCXut7MmU kPpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=OEH2s43n/iE/mG5v/jFLFkRmYPc8FGzyJHkswbJxF6M=; b=dJ17Obuy79KXoY3bwCYLfzi6cRV/iAEe7w4D1SKKBXJgsFyQUdPEXKDmctCMnnlJzm AkXJKomEZY0O+to9/d4Cnut+pRbgaXa0GOKdTp069dBQSICfJSD4Wz0InBvQ9WzLCoxd v2NZLe9ZHZX28sIzI6Vf8lIYcGbwJpulx1tke5G/62nkAcMEZEpS6aZBGCIRHLZQkeGS +1Csmto15wnhlrxSrDjgyBvErS3oA2BHVAKSxrmEoY4161+WTt47adCdyFJ7h/bp0PrD 7P8QXF7hUOjjWsvI+EfAd/lwSD/QzjIMDextBI2PKafx0wTs1dcMSlhBjY3liiKxMugz Lyhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fu2ES9d7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id pg6-20020a170907204600b0095727b08140si5711565ejb.239.2023.05.29.01.50.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:50:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fu2ES9d7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 208DB3893640 for ; Mon, 29 May 2023 08:40:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 208DB3893640 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349647; bh=OEH2s43n/iE/mG5v/jFLFkRmYPc8FGzyJHkswbJxF6M=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Fu2ES9d7WkzSdGCxbtE8BmG1+gqR7+92JBNgMH/TndkjL33vKs+oVi49GbVmxkW3B 1R23ly6QpIzzHodyDEPtFs9Wy7PNQBP0GsIBd2/m+imqs6tVlU/z2B7yyOHw3wuAlI H7EhD4JySFQ3JV3n6HnEbZ+1LmjAkz+/d+boKVRc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 108C6384645D for ; Mon, 29 May 2023 08:29:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 108C6384645D Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-30959c0dfd6so2922472f8f.3 for ; Mon, 29 May 2023 01:29:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685348982; x=1687940982; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OEH2s43n/iE/mG5v/jFLFkRmYPc8FGzyJHkswbJxF6M=; b=govqSrZldZwFdAufLN1MxmLynXnwD0qQnbNuAMeJB3jR7Q7/fZHJA4B68MiM4rzR3P BtU0+Xk2epU8H4vpenkISqJ8BGWCGKQnJiT/Et+piE5x+YfcYQDlXyTw5KDTkvnDENKh vtiWoxt1RuwAq8vJyogfN/eBgu4Ue0cLFrag+KU8lx/d9lIVCCNlL/P7BfH6SPT1PG3t sC8YzyK++mRRnF4BzZPjPOOkFICxhwOWGOHMCS83cWAHYjhPI/49r79qa+DyWK7bxbiA 642Q1UrjD/T9mW4hNUHYNbmOjeNyNRAP3QQNTyAo5BZo8VI/v1M6x58Sdxpi2b11b9x5 QWbw== X-Gm-Message-State: AC+VfDxX2ac+4uiCpk9BJe3+TJ39bdPurmqJxqRV3RYD1s3TKmZf9Ggl Fwhy+ubbMmC0spwJhIffA03o1Vkxiu2w1MYYf0BcYQ== X-Received: by 2002:adf:e902:0:b0:30a:e997:e69c with SMTP id f2-20020adfe902000000b0030ae997e69cmr2554931wrm.53.1685348981970; Mon, 29 May 2023 01:29:41 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id z16-20020adfe550000000b003063a92bbf5sm13145755wrm.70.2023.05.29.01.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:29:41 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Cleanup detection of type support subprogram entities Date: Mon, 29 May 2023 10:29:40 +0200 Message-Id: <20230529082940.2410752-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767217794740831511?= X-GMAIL-MSGID: =?utf-8?q?1767217794740831511?= From: Piotr Trojanek Avoid repeated calls to Get_TSS_Name. Code cleanup related to handling of dispatching operations in GNATprove; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Convert_Aggr_In_Allocator): Replace Get_TSS_Name with a high-level Is_TSS. * sem_ch6.adb (Check_Conformance): Replace DECLARE block and nested IF with a call to Get_TSS_Name and a membership test. (Has_Reliable_Extra_Formals): Refactor repeated calls to Get_TSS_Name. * sem_disp.adb (Check_Dispatching_Operation): Replace repeated calls to Get_TSS_Name with a membership test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 3 +- gcc/ada/sem_ch6.adb | 73 +++++++++++++++++++------------------------- gcc/ada/sem_disp.adb | 6 ++-- 3 files changed, 35 insertions(+), 47 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index c4a016ed3d4..93fcac5439e 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4487,8 +4487,7 @@ package body Exp_Aggr is while Present (Stmt) loop if Nkind (Stmt) = N_Procedure_Call_Statement - and then Get_TSS_Name (Entity (Name (Stmt))) - = TSS_Slice_Assign + and then Is_TSS (Entity (Name (Stmt)), TSS_Slice_Assign) then Param := First (Parameter_Associations (Stmt)); Insert_Actions diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 495e8b1c538..17c50f6e676 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -6005,41 +6005,35 @@ package body Sem_Ch6 is -- avoids some redundant error messages. and then not Error_Posted (New_Formal) - then - -- It is allowed to omit the null-exclusion in case of stream - -- attribute subprograms. We recognize stream subprograms - -- through their TSS-generated suffix. - declare - TSS_Name : constant TSS_Name_Type := Get_TSS_Name (New_Id); + -- It is allowed to omit the null-exclusion in case of stream + -- attribute subprograms. We recognize stream subprograms + -- through their TSS-generated suffix. - begin - if TSS_Name /= TSS_Stream_Read - and then TSS_Name /= TSS_Stream_Write - and then TSS_Name /= TSS_Stream_Input - and then TSS_Name /= TSS_Stream_Output - then - -- Here we have a definite conformance error. It is worth - -- special casing the error message for the case of a - -- controlling formal (which excludes null). + and then Get_TSS_Name (New_Id) not in TSS_Stream_Read + | TSS_Stream_Write + | TSS_Stream_Input + | TSS_Stream_Output + then + -- Here we have a definite conformance error. It is worth + -- special casing the error message for the case of a + -- controlling formal (which excludes null). - if Is_Controlling_Formal (New_Formal) then - Error_Msg_Node_2 := Scope (New_Formal); - Conformance_Error - ("\controlling formal & of & excludes null, " - & "declaration must exclude null as well", - New_Formal); + if Is_Controlling_Formal (New_Formal) then + Error_Msg_Node_2 := Scope (New_Formal); + Conformance_Error + ("\controlling formal & of & excludes null, " + & "declaration must exclude null as well", + New_Formal); - -- Normal case (couldn't we give more detail here???) + -- Normal case (couldn't we give more detail here???) - else - Conformance_Error - ("\type of & does not match!", New_Formal); - end if; + else + Conformance_Error + ("\type of & does not match!", New_Formal); + end if; - return; - end if; - end; + return; end if; end if; @@ -10650,21 +10644,16 @@ package body Sem_Ch6 is else declare - Typ : constant Entity_Id := - Underlying_Type (Find_Dispatching_Type (Alias_E)); + TSS_Name : constant TSS_Name_Type := Get_TSS_Name (E); + Typ : constant Entity_Id := + Underlying_Type (Find_Dispatching_Type (Alias_E)); begin - if (Get_TSS_Name (E) = TSS_Stream_Input - and then not Stream_Operation_OK (Typ, TSS_Stream_Input)) - or else - (Get_TSS_Name (E) = TSS_Stream_Output - and then not Stream_Operation_OK (Typ, TSS_Stream_Output)) - or else - (Get_TSS_Name (E) = TSS_Stream_Read - and then not Stream_Operation_OK (Typ, TSS_Stream_Read)) - or else - (Get_TSS_Name (E) = TSS_Stream_Write - and then not Stream_Operation_OK (Typ, TSS_Stream_Write)) + if TSS_Name in TSS_Stream_Input + | TSS_Stream_Output + | TSS_Stream_Read + | TSS_Stream_Write + and then not Stream_Operation_OK (Typ, TSS_Name) then return False; end if; diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb index ab409d3a4e4..6c8212c3cb3 100644 --- a/gcc/ada/sem_disp.adb +++ b/gcc/ada/sem_disp.adb @@ -1414,9 +1414,9 @@ package body Sem_Disp is and then Is_Null_Interface_Primitive (Ultimate_Alias (Old_Subp))) - or else Get_TSS_Name (Subp) = TSS_Stream_Read - or else Get_TSS_Name (Subp) = TSS_Stream_Write - or else Get_TSS_Name (Subp) = TSS_Put_Image + or else Get_TSS_Name (Subp) in TSS_Stream_Read + | TSS_Stream_Write + | TSS_Put_Image or else (Is_Wrapper (Subp)