From patchwork Tue Nov 8 08:42:38 2022 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: 16946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2572370wru; Tue, 8 Nov 2022 00:52:00 -0800 (PST) X-Google-Smtp-Source: AMsMyM7Jva1sHiR7HnWWIQtFELywuOMfUbwrVYIrGizHuEvvN9VmaIfwjIeBkZzSLanH/vYJwltE X-Received: by 2002:a50:d6c7:0:b0:464:4a78:c84c with SMTP id l7-20020a50d6c7000000b004644a78c84cmr26523001edj.144.1667897520469; Tue, 08 Nov 2022 00:52:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667897520; cv=none; d=google.com; s=arc-20160816; b=msO9/Le/oS+HDZ7dVoHzg2jJl3yHi/MSpyBi83zKTpUnaKgDXYFqzsH4y4m3qOvpV4 y7O1F7U7ZPTgorLDf6tXIFzKjxJmkOfyiWpaUYr6AGqKh98dfKH6Q/6V/eSB3JDNL/P+ kNiILZHWpAOuuQv3iA9vgjumsMLoFkN1kqd+fNtGh7p0R7jjldovSS774YoLWMaKpsSm 1gR/WNbvt4NZPxzf3sNfAwAGxu/HP6czG2Bs8/DBwim7jrzbdSvHaWhkDWfhonl0IZBR ppK4e545sdgyXpizLMT2QPnqouxOAubQVzqlxbczLkIOIVCJDuzxsQe1l4W6qWEeBVBu 8+Bg== 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=faAS903hcXFKR+t9cAaT4WzOzycXOmYINZD5VvDmEYU=; b=qh97PHoXq0PCzMQ11oBdmdRNS/nG2fmrS5YnpqEhIxEEAJhCMQ5jWzlRK+zeoW2QW1 uLpzYJbUPrsXWS4yxouTtkJ0pdXu8i0j6bXiNX3Be9eqP5leHrPqMArJokZLZ6B75x4J tEdZPEeNOQHt+HxYUI7n7MU6oClPr10S8lCRRsjH+6RxyMeTyu+LSsN631xyeJMJ/Rs7 AezcHVtvBVLnaK4/7Se4iO64u/iB/4CF4IivItetWc5LgAveMoznc1Nweg+3Mw7ElRCh NMthE7AkQ9C8U1T+r7mT3kahyM7/j/h0mZzGgn+7YGvtNvgA9Gg6/rBKkhQekpPI4XwS mGFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MIG5pKjy; 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 l3-20020a170907914300b007a7d37e4681si8800438ejs.845.2022.11.08.00.52.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:52:00 -0800 (PST) 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=MIG5pKjy; 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 5B05E3854163 for ; Tue, 8 Nov 2022 08:49:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B05E3854163 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667897375; bh=faAS903hcXFKR+t9cAaT4WzOzycXOmYINZD5VvDmEYU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=MIG5pKjy6QsmCd8p4W3cWconJ70d1iPHPf3yQb9Ez4NmDWHw9fefstENFbJyrjQbK Y682VqfdupsKe0C+9uzCFJoOQu5GFvAJ9WLsPnQEdCDOdwElJdTu+/NHw9z3dY+joR yQIhAb0D1Dms0NpSM02FKDqfL0v1pwh4tTIpyKwU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 214F638582BB for ; Tue, 8 Nov 2022 08:42:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 214F638582BB Received: by mail-wr1-x42d.google.com with SMTP id w14so19770036wru.8 for ; Tue, 08 Nov 2022 00:42:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=faAS903hcXFKR+t9cAaT4WzOzycXOmYINZD5VvDmEYU=; b=cV3taQhOOWQKbb5n+Z9S/cSGuqv/o3JoCC1QXVqmGVuYeQaICAy+qRpaZMINFpQfUg czjwnBoeDegSyd2zYlJIZvn2+P31j6eeZlwyJSwHF6YArZLtMY6gLMK01dYBYvsNLRIU F4eLD2anJa0hWYdBRNmMbfB0mXQgOwEnaffzhj1JuBkMM7XCVao++4cN6cJItqYGOdH5 +hsN53vwUoiIxdJQw880mIf5bAA0AEFFpNrSGEebVPoIlplki7BaVMGUSZ8Toc8+EIe8 h7ldhrSupGR4irmD/HK/XLjYnxS1SSsEheL7xPnSrpUAvrEqCx3DR/C2lFjqTMZKXc2b CsYA== X-Gm-Message-State: ACrzQf0KpHUGB4sxkwEYoEx6hLypge1oS0IcDs3K6Zu/qThG5COmgEQV dw7J4jB8l8I2n4lqAwYQOZQ8kouKnSbcpQ== X-Received: by 2002:a5d:6d0b:0:b0:236:f055:e561 with SMTP id e11-20020a5d6d0b000000b00236f055e561mr21059146wrq.166.1667896961773; Tue, 08 Nov 2022 00:42:41 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id n1-20020a1ca401000000b003cf66a2d433sm13513492wme.33.2022.11.08.00.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:42:41 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Minor consistency tweaks in Sem_Ch4 Date: Tue, 8 Nov 2022 09:42:38 +0100 Message-Id: <20221108084238.301516-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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?1748917310587457601?= X-GMAIL-MSGID: =?utf-8?q?1748917310587457601?= From: Eric Botcazou This ensures that, during the analysis of the qualified expressions, type conversions and unchecked type conversions, the determination of the type of the node and the analysis of its expression are done in the same order. No functional changes. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Analyze the expression only after setting the type. (Analyze_Unchecked_Type_Conversion): Likewise. (Analyze_Short_Circuit): Likewise for the operands. (Analyze_Type_Conversion): Minor tweaks. (Analyze_Unchecked_Expression): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 489fb47247a..0c02fd80675 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4323,16 +4323,14 @@ package body Sem_Ch4 is ---------------------------------- procedure Analyze_Qualified_Expression (N : Node_Id) is - Mark : constant Entity_Id := Subtype_Mark (N); Expr : constant Node_Id := Expression (N); + Mark : constant Entity_Id := Subtype_Mark (N); + I : Interp_Index; It : Interp; T : Entity_Id; begin - Analyze_Expression (Expr); - - Set_Etype (N, Any_Type); Find_Type (Mark); T := Entity (Mark); @@ -4353,6 +4351,8 @@ package body Sem_Ch4 is Set_Etype (N, T); + Analyze_Expression (Expr); + if T = Any_Type then return; end if; @@ -5948,9 +5948,9 @@ package body Sem_Ch4 is It : Interp; begin + Set_Etype (N, Any_Type); Analyze_Expression (L); Analyze_Expression (R); - Set_Etype (N, Any_Type); if not Is_Overloaded (L) then if Root_Type (Etype (L)) = Standard_Boolean @@ -6083,7 +6083,9 @@ package body Sem_Ch4 is ----------------------------- procedure Analyze_Type_Conversion (N : Node_Id) is - Expr : constant Node_Id := Expression (N); + Expr : constant Node_Id := Expression (N); + Mark : constant Entity_Id := Subtype_Mark (N); + Typ : Entity_Id; begin @@ -6100,11 +6102,13 @@ package body Sem_Ch4 is -- Otherwise full type analysis is required, as well as some semantic -- checks to make sure the argument of the conversion is appropriate. - Find_Type (Subtype_Mark (N)); - Typ := Entity (Subtype_Mark (N)); + Find_Type (Mark); + Typ := Entity (Mark); Set_Etype (N, Typ); - Check_Fully_Declared (Typ, N); + Analyze_Expression (Expr); + + Check_Fully_Declared (Typ, N); Validate_Remote_Type_Type_Conversion (N); -- Only remaining step is validity checks on the argument. These @@ -6227,10 +6231,12 @@ package body Sem_Ch4 is ---------------------------------- procedure Analyze_Unchecked_Expression (N : Node_Id) is + Expr : constant Node_Id := Expression (N); + begin - Analyze (Expression (N), Suppress => All_Checks); - Set_Etype (N, Etype (Expression (N))); - Save_Interps (Expression (N), N); + Analyze (Expr, Suppress => All_Checks); + Set_Etype (N, Etype (Expr)); + Save_Interps (Expr, N); end Analyze_Unchecked_Expression; --------------------------------------- @@ -6238,10 +6244,13 @@ package body Sem_Ch4 is --------------------------------------- procedure Analyze_Unchecked_Type_Conversion (N : Node_Id) is + Expr : constant Node_Id := Expression (N); + Mark : constant Entity_Id := Subtype_Mark (N); + begin - Find_Type (Subtype_Mark (N)); - Analyze_Expression (Expression (N)); - Set_Etype (N, Entity (Subtype_Mark (N))); + Find_Type (Mark); + Set_Etype (N, Entity (Mark)); + Analyze_Expression (Expr); end Analyze_Unchecked_Type_Conversion; ------------------------------------