From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 6BD31384514A for ; Thu, 16 May 2024 09:26:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BD31384514A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6BD31384514A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851594; cv=none; b=I+OvCkmdPYmdLaOYZPxb0Wwlh48fIxcHyj2XRVWcMSqEBfBLRG1kupXMxbObT1NMNeIy6/Y8J2aTZpDakM921jCciQYlvwR0/BAqBGJusf4oESjdCbrxjOvanwL4HiXJWqNKYT4sFjeezDNdCWAbptjc7VuT2rfi/vhqOnJl410= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851594; c=relaxed/simple; bh=AWNu10gvoBCoatsPT6KoJpgcZFuW5TzpsBTJPMyauOs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Jg94NAwN5vKdimwNYKZ8WXY0G8Mf/gqqKw0CVdaapSiEeOwpmKGtEHWYI7DzFj6eEDzi53EVUA9wA6dot32lULXUelM5CdcIXh3aYdrxgxxoehb8tPLp5Z6T8bsQuHPNd/P1rHrfH7QieJPqopamIgi5m2gpJKBNYGFFNnQMZEY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-41fd5dc04f0so50777805e9.0 for ; Thu, 16 May 2024 02:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1715851585; x=1716456385; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qfNrh/zu9MR7SxmGCReD7h2TUEEAo8+BhQBdK6uaTvk=; b=ZJRPQ++J8G9CSmjPUAVXI1T0I1md/7Q8LTuwuFAwVkFq4GN7W1uE2MrWND5iYOOrd1 oUPWGuhco4En/g2UUFpz6CsGQhq7JYsICor6pvthNuLHfWbEMwdILsPQ29ajfRIJmNnb R9JRKS9wvOO8rj7fGqiTNw/ZepQ0iQA9Ekx5wEdSnq00O3Aqbm0PeY9jgm/MCh6ByA6N f4VX5dqQEiekOmuZ4rJHNij1o1IpHREHVs0YOgx3Le4gf1aZxL+Dfpwh3/H4ay5df9f8 Rg4RbcneJcP+l4O7Rzn7AvwFoWaHfydPvzAJhJ0dYqEOPfpuxXIv8PjDlXIBJBieM899 kXJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715851585; x=1716456385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qfNrh/zu9MR7SxmGCReD7h2TUEEAo8+BhQBdK6uaTvk=; b=uK6hZt9l8O4LarLAr2HmBkVSy3eLAJc+EWRw08BxrMafZ6QrDJU/vvj10ny7zD6GTf 0sDQhWYvrtKiYeQNxkbSWj9jahMBHvPkZBzl9k3gYGnEBQNuTOSrQ5ryJjwHdGYhcoRm qmKm14NHNIboHkqEsoUdidDZXNNwr6Fi9zFgfs6WzUJKYxKowboSe0WgsVVKFxPaXOI9 6NIQmCg617MZtIuKMKWhuUnEpMQ1HnOn05HSwgo6NjOil1oAdeGAtTYE5W+Qb+nBMohZ R3O7pjsWFF7y36l6vIBjSyBBa84rFnhobQOptx5iNJ4RRlr/yHz1zsh5mywrpx7BQZCE nKKA== X-Gm-Message-State: AOJu0Yy2plU4q0huf1Jk3bkJwUe7nQwRpKYmvL2xXQCoELu4cdBWIHKZ DKNTdOFLi6TKr5e7K0sC8lfBCW7tie2KGNMesdbQL0mdRzDFoaLqsT+xv1lEo5Nb1GrqjKPnq3g = X-Google-Smtp-Source: AGHT+IEneP4D2qYkm91VYmUPSKZemAxSCXdA2wOR8PwGqExVhwMFIRzVI5TFcgKouoDSAXJ9+w95DQ== X-Received: by 2002:a05:600c:4f0c:b0:420:1f0f:fe19 with SMTP id 5b1f17b1804b1-4201f0fff56mr83689935e9.13.1715851585317; Thu, 16 May 2024 02:26:25 -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 5b1f17b1804b1-41fd10cf8besm135802635e9.1.2024.05.16.02.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:26:24 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 22/35] ada: No need to follow New_Occurrence_Of with Set_Etype Date: Thu, 16 May 2024 11:25:51 +0200 Message-ID: <20240516092606.41242-22-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516092606.41242-1-poulhies@adacore.com> References: <20240516092606.41242-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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: Piotr Trojanek Routine New_Occurrence_Of itself sets the Etype of its result; there is no need to set it explicitly afterwards. Code cleanup related to fix for attribute 'Old; semantics is unaffected. gcc/ada/ * exp_ch13.adb (Expand_N_Free_Statement): After analysis, the new temporary has the type of its Object_Definition and the new occurrence of this temporary has this type as well; simplify. * sem_util.adb (Indirect_Temp_Value): Remove redundant call to Set_Etype; simplify. (Is_Access_Type_For_Indirect_Temp): Add missing body header. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch13.adb | 9 ++------- gcc/ada/sem_util.adb | 11 +++++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gcc/ada/exp_ch13.adb b/gcc/ada/exp_ch13.adb index 2d5ee9b6e80..af8c925586c 100644 --- a/gcc/ada/exp_ch13.adb +++ b/gcc/ada/exp_ch13.adb @@ -358,21 +358,16 @@ package body Exp_Ch13 is declare Expr_Typ : constant Entity_Id := Etype (Expr); Loc : constant Source_Ptr := Sloc (N); - New_Expr : Node_Id; - Temp_Id : Entity_Id; + Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); begin - Temp_Id := Make_Temporary (Loc, 'T'); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Temp_Id, Object_Definition => New_Occurrence_Of (Expr_Typ, Loc), Expression => Relocate_Node (Expr))); - New_Expr := New_Occurrence_Of (Temp_Id, Loc); - Set_Etype (New_Expr, Expr_Typ); - - Set_Expression (N, New_Expr); + Set_Expression (N, New_Occurrence_Of (Temp_Id, Loc)); end; end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 766cabfc109..5ebb1319de7 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -31081,8 +31081,7 @@ package body Sem_Util is begin if Is_Anonymous_Access_Type (Typ) then -- No indirection in this case; just evaluate the temp. - Result := New_Occurrence_Of (Temp, Loc); - Set_Etype (Result, Etype (Temp)); + return New_Occurrence_Of (Temp, Loc); else Result := Make_Explicit_Dereference (Loc, @@ -31101,11 +31100,15 @@ package body Sem_Util is Set_Etype (Result, Typ); end if; - end if; - return Result; + return Result; + end if; end Indirect_Temp_Value; + -------------------------------------- + -- Is_Access_Type_For_Indirect_Temp -- + -------------------------------------- + function Is_Access_Type_For_Indirect_Temp (T : Entity_Id) return Boolean is begin -- 2.43.2