From patchwork Thu Jun 20 08:53:05 2024 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: 1950019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=eVKSGeHi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4Zcq3ndrz20X6 for ; Thu, 20 Jun 2024 19:16:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B270238930CE for ; Thu, 20 Jun 2024 09:16:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 2A6283888C74 for ; Thu, 20 Jun 2024 08:53:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A6283888C74 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 2A6283888C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718873628; cv=none; b=UZMpEoBunkOKtDQ9ybYhVukBuHGCV4byMWy4/4qsBU6LVfVwPthAckkaIfO5ECmwcWL0EQ6/uEQE75ldRn6kKh+Fvyl8DcE+Rze+9cFdqqVUMoIo79m460E/XpFeh0lNUeYOxAD4AtuWu//5/BQxP8fJJhyHkzwuGfNawKHQa1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718873628; c=relaxed/simple; bh=Gx5h2LyefH9sWJTflibAhWc/NnaEDgtk+0aGf7RCgHs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cO7Mhs1ReeU7Af+nwYKjB/9M4jQN+YZpgO/yH0g8vxdm0griDmNBf1WrOe4Xj7wOPBM5rvDMAwSGUAErSlvGLXqEh+fD9JPT9g/Tf0HcsB9Dx48zcwYuReoZWpsKmbFU07Iqi6GIagvDXJ84gpv3I9ltx5a7NmjsTA5q8QD886U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-361785bfa71so585707f8f.2 for ; Thu, 20 Jun 2024 01:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718873623; x=1719478423; 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=Orimv94JDuG6wx8T0cZHMhyDBw05VvD0M8uwE4NCPys=; b=eVKSGeHiDlBiEMX+1hG0ITjYZCFEX+LxJP0nGTL/0p4JNAW7GQClNQsDjBI2lxfu4U T1IwnCQAgOztPnb8mlWNbbFLZcNB7KWhZHlHlGwl+/qiWloKUxET7KxagCZdarIz4ppT cBxU2BDCzAaGUIL8yfvjKKHFWDjnluwFgIVeNzond2TyLeB1ehLZKbbr9o2mZe5PPNMh a69DY3PNMZJGOw9urpYEX/XoN/e7KHF2nkFt/VuBHcaIitPDk9VfCYaR6ASFjTsMSNf7 2SdmtNUuFT/HXsYBmwxB2+hqGhFRaj4L0MeZTNra796A+UyxdvCWiGFueAfMjsEJajwX fVCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718873623; x=1719478423; 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=Orimv94JDuG6wx8T0cZHMhyDBw05VvD0M8uwE4NCPys=; b=fyWljguPyPqCIeQgf0CkQK0XLTCzFWi+PYyevfC4kiYo7EhRprEJJ/thHORhcuDcya JA8bUSfWrpsIVPsxPbkyVcaV+th1fJdDd3BpdiVJaXLJA0ME2bsZpz0LiCTDiheV/zrR DZ7uhxovlG+DY8zjXVAzgKXnRRt48NbnhGvcVJyT0zRTDin2PnRJeQwFCRdEZe1Jg1uJ JZoIXkzK/yJFXpjuD4u61sudKZVAJfz0O81rr/a3p0FX3ihrgRvf9whlZfhiXdY+B3CH foKyKl1/IpTnIvXmoppab3BriYHuhmzzEhmhNv9r28NP+n8VeIzJ9uR3lhVZh5Jf0LH4 BhUQ== X-Gm-Message-State: AOJu0Yx8DV/JbSl8StAoCg2u52PmHtsvD8QkFcsMmLh6eHbaNphlgjwc DM0cGR+9eGi43VvTXgA6YN9SaB8mxqeskSsMKXJR2aDDY6E3FwceBfQ3IrAVRs8YqvU/GTVxc3g = X-Google-Smtp-Source: AGHT+IGUgtqeL6OTmv0TUkY+gUabqNxNO+4qR+go0sR49VbNN8DhdHQx7KZngPnoWgdTU2/npi3ABg== X-Received: by 2002:a5d:4b0d:0:b0:35f:29a8:2abc with SMTP id ffacd0b85a97d-363192cdf2cmr3471059f8f.56.1718873622852; Thu, 20 Jun 2024 01:53:42 -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 ffacd0b85a97d-363c795febfsm3305522f8f.104.2024.06.20.01.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 01:53:42 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 15/30] ada: Remove redundant conditions from freezing code Date: Thu, 20 Jun 2024 10:53:05 +0200 Message-ID: <20240620085321.2412421-15-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240620085321.2412421-1-poulhies@adacore.com> References: <20240620085321.2412421-1-poulhies@adacore.com> 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Piotr Trojanek Code cleanup; behavior is unaffected. gcc/ada/ * freeze.adb (Check_Current_Instance): This routine is only called with parameter E being a type entity, so there is no need to check for types just before the equality with E. * sem_ch13.adb (Analyze_Aspect_Specifications): Regroup condition to avoid unnecessary evaluation. (Check_Aspect_At_End_Of_Declarations): If In_Instance is true, then the routine exits early. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 1 - gcc/ada/sem_ch13.adb | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 2fcc2ce02e7..2a0a59f5b03 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -3086,7 +3086,6 @@ package body Freeze is when N_Attribute_Reference => if Attribute_Name (N) in Name_Access | Name_Unchecked_Access and then Is_Entity_Name (Prefix (N)) - and then Is_Type (Entity (Prefix (N))) and then Entity (Prefix (N)) = E then if Ada_Version < Ada_2012 then diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index f65217b0b90..d81b7412313 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4086,12 +4086,12 @@ package body Sem_Ch13 is Error_Msg_N ("aspect% cannot apply to subtype", Id); goto Continue; - elsif A_Id = Aspect_Default_Value - and then not Is_Scalar_Type (E) - then - Error_Msg_N - ("aspect% can only be applied to scalar type", Id); - goto Continue; + elsif A_Id = Aspect_Default_Value then + if not Is_Scalar_Type (E) then + Error_Msg_N + ("aspect% can only be applied to scalar type", Id); + goto Continue; + end if; elsif A_Id = Aspect_Default_Component_Value then if not Is_Array_Type (E) then @@ -11118,7 +11118,7 @@ package body Sem_Ch13 is -- If the end of declarations comes before any other freeze point, -- the Freeze_Expr is not analyzed: no check needed. - if Analyzed (Freeze_Expr) and then not In_Instance then + if Analyzed (Freeze_Expr) then Check_Overloaded_Name; else Err := False;