From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id E7AC1385800C for ; Tue, 13 Jun 2023 07:38:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E7AC1385800C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f8c5d0b19dso6523695e9.1 for ; Tue, 13 Jun 2023 00:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686641895; x=1689233895; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jGHWUpm21qI/dUhwKeb09LdsH4lC2CfrZzTsFDbaemo=; b=IwX8dNQISCb6luNsC6bsbY5onpoh9bWsO9gskN3b5IlwuQTrLx4icRO9jxXYx14uFI CE9wYbp9qfNtIgmNFBRigCpUqxj9Coqj/a8XXlamiN18sFlnYElTuhtbT5CMD33fP8IG RWwOZjP7nDn6mcxgRkxmboTrHiGPdjWTVhM28gjiWz+TrGiJfDHwZU+jttVi/3FA6NoA l4AIV5TflLZ738npKjQjoBBTlhKPyq1GI/JSQdD3MJNDrr+NqJ+yBrhph5/v904qce/8 3mngkfIhD8Kf/ye4qElNHa2HV1ddIURfM4J8dSMsZjRmzlXdiLjFj73K35Rt7YB0v0vv u5lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686641895; x=1689233895; 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=jGHWUpm21qI/dUhwKeb09LdsH4lC2CfrZzTsFDbaemo=; b=Io2MYW3Twdh2dcHvUHLCTGfr8FJuN563gM3P/Sf1n9XUMdydC5RDUyLXoaB8qQqKqS LLircr7LZY8L2QbtEWq4pEOJjGGPBBDmpeAIbjDUlibrBsJZfcuwUtfqEkWUMvpazP6V 81DN5XlNwcprVa5h/aJGuEzP3zdxi9IHIU9P3zmkyjb7JxGorkUGaqI5zyvXnyvprtxz 5TXrEg1Qez6Ys9tdQuFbtPLhchJtOo2X+BhuvQuH1G1kqJeh2YSD+Gytw1Xvqo1lvSfH bwDetc2ksStFY+xaYcJoHLZS8pVo0PBXfC2J3S/secMJibAP4l/0Tu9GdLc0cz77IitP UtdQ== X-Gm-Message-State: AC+VfDwde5SLF1rE64qz9FH96fOFywvyZfFZRJvGVyFAsGNIXCueGU8c KnNfBJv2mzicrZRaCCS17pQDT9fFDWMpY2wBiu48Rg== X-Google-Smtp-Source: ACHHUZ7cvBj4o9B4Ciw4pch3Rdq8Ind0e1CrQBR7n/KNYw0k+oEAsbkRlQr3vcHpXr9SlzPlZRNTFg== X-Received: by 2002:a1c:7713:0:b0:3f7:5d:49ff with SMTP id t19-20020a1c7713000000b003f7005d49ffmr9604881wmi.1.1686641895734; Tue, 13 Jun 2023 00:38:15 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:bfa8:5d29:40e5:cc66]) by smtp.gmail.com with ESMTPSA id 26-20020a05600c029a00b003f7298a32ccsm13533607wmk.41.2023.06.13.00.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:38:15 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Remove obsolete code in Analyze_Assignment Date: Tue, 13 Jun 2023 09:38:14 +0200 Message-Id: <20230613073814.239864-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,KAM_ASCII_DIVIDERS,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 List-Id: From: Eric Botcazou This code was dealing with build-in-place calls for nonlimited types, but they no longer exist since Is_Build_In_Place_Result_Type => Is_Limited_View. gcc/ada/ * sem_ch5.adb (Analyze_Assignment): Turn Rhs into a constant and remove calls to the following subprograms. (Transform_BIP_Assignment): Delete. (Should_Transform_BIP_Assignment): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 156 +------------------------------------------- 1 file changed, 1 insertion(+), 155 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 99a57573a87..f9174869a26 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -113,7 +113,7 @@ package body Sem_Ch5 is procedure Analyze_Assignment (N : Node_Id) is Lhs : constant Node_Id := Name (N); - Rhs : Node_Id := Expression (N); + Rhs : constant Node_Id := Expression (N); procedure Diagnose_Non_Variable_Lhs (N : Node_Id); -- N is the node for the left hand side of an assignment, and it is not @@ -137,27 +137,6 @@ package body Sem_Ch5 is -- nominal subtype. This procedure is used to deal with cases where the -- nominal subtype must be replaced by the actual subtype. - procedure Transform_BIP_Assignment (Typ : Entity_Id); - function Should_Transform_BIP_Assignment - (Typ : Entity_Id) return Boolean; - -- If the right-hand side of an assignment statement is a build-in-place - -- call we cannot build in place, so we insert a temp initialized with - -- the call, and transform the assignment statement to copy the temp. - -- Transform_BIP_Assignment does the transformation, and - -- Should_Transform_BIP_Assignment determines whether we should. - -- The same goes for qualified expressions and conversions whose - -- operand is such a call. - -- - -- This is only for nonlimited types; assignment statements are illegal - -- for limited types, but are generated internally for aggregates and - -- init procs. These limited-type are not really assignment statements - -- -- conceptually, they are initializations, so should not be - -- transformed. - -- - -- Similarly, for nonlimited types, aggregates and init procs generate - -- assignment statements that are really initializations. These are - -- marked No_Ctrl_Actions. - function Within_Function return Boolean; -- Determine whether the current scope is a function or appears within -- one. @@ -354,87 +333,6 @@ package body Sem_Ch5 is end if; end Set_Assignment_Type; - ------------------------------------- - -- Should_Transform_BIP_Assignment -- - ------------------------------------- - - function Should_Transform_BIP_Assignment - (Typ : Entity_Id) return Boolean - is - begin - if Expander_Active - and then not Is_Limited_View (Typ) - and then Is_Build_In_Place_Result_Type (Typ) - and then not No_Ctrl_Actions (N) - then - -- This function is called early, before name resolution is - -- complete, so we have to deal with things that might turn into - -- function calls later. N_Function_Call and N_Op nodes are the - -- obvious case. An N_Identifier or N_Expanded_Name is a - -- parameterless function call if it denotes a function. - -- Finally, an attribute reference can be a function call. - - declare - Unqual_Rhs : constant Node_Id := Unqual_Conv (Rhs); - begin - case Nkind (Unqual_Rhs) is - when N_Function_Call - | N_Op - => - return True; - - when N_Expanded_Name - | N_Identifier - => - return - Ekind (Entity (Unqual_Rhs)) in E_Function | E_Operator; - - -- T'Input will turn into a call whose result type is T - - when N_Attribute_Reference => - return Attribute_Name (Unqual_Rhs) = Name_Input; - - when others => - return False; - end case; - end; - else - return False; - end if; - end Should_Transform_BIP_Assignment; - - ------------------------------ - -- Transform_BIP_Assignment -- - ------------------------------ - - procedure Transform_BIP_Assignment (Typ : Entity_Id) is - - -- Tranform "X : [constant] T := F (...);" into: - -- - -- Temp : constant T := F (...); - -- X := Temp; - - Loc : constant Source_Ptr := Sloc (N); - Def_Id : constant Entity_Id := Make_Temporary (Loc, 'Y', Rhs); - Obj_Decl : constant Node_Id := - Make_Object_Declaration (Loc, - Defining_Identifier => Def_Id, - Constant_Present => True, - Object_Definition => New_Occurrence_Of (Typ, Loc), - Expression => Rhs, - Has_Init_Expression => True); - - begin - Set_Etype (Def_Id, Typ); - Set_Expression (N, New_Occurrence_Of (Def_Id, Loc)); - - -- At this point, Rhs is no longer equal to Expression (N), so: - - Rhs := Expression (N); - - Insert_Action (N, Obj_Decl); - end Transform_BIP_Assignment; - --------------------- -- Within_Function -- --------------------- @@ -610,56 +508,6 @@ package body Sem_Ch5 is end if; end if; - -- Deal with build-in-place calls for nonlimited types. We don't do this - -- later, because resolving the rhs tranforms it incorrectly for build- - -- in-place. - - if Should_Transform_BIP_Assignment (Typ => T1) then - - -- In certain cases involving user-defined concatenation operators, - -- we need to resolve the right-hand side before transforming the - -- assignment. - - case Nkind (Unqual_Conv (Rhs)) is - when N_Function_Call => - declare - Actual : Node_Id := - First (Parameter_Associations (Unqual_Conv (Rhs))); - Actual_Exp : Node_Id; - - begin - while Present (Actual) loop - if Nkind (Actual) = N_Parameter_Association then - Actual_Exp := Explicit_Actual_Parameter (Actual); - else - Actual_Exp := Actual; - end if; - - if Nkind (Actual_Exp) = N_Op_Concat then - Resolve (Rhs, T1); - exit; - end if; - - Next (Actual); - end loop; - end; - - when N_Attribute_Reference - | N_Expanded_Name - | N_Identifier - | N_Op - => - null; - - when others => - raise Program_Error; - end case; - - Transform_BIP_Assignment (Typ => T1); - end if; - - pragma Assert (not Should_Transform_BIP_Assignment (Typ => T1)); - -- The resulting assignment type is T1, so now we will resolve the left -- hand side of the assignment using this determined type. @@ -1303,8 +1151,6 @@ package body Sem_Ch5 is Full_Analysis := Save_Full_Analysis; Current_Assignment := Empty; end if; - - pragma Assert (not Should_Transform_BIP_Assignment (Typ => T1)); end if; end Analyze_Assignment; -- 2.40.0