From patchwork Thu Oct 19 14:41:50 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: 155624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp433031vqb; Thu, 19 Oct 2023 07:42:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeSeRKG7qlAX301PDsjL2TgZ0P1rSne1QUJq+nkEu94ZCA5v0lQThuIdwDiYuxwMU0qTt5 X-Received: by 2002:a05:6214:4001:b0:65d:f81:9b47 with SMTP id kd1-20020a056214400100b0065d0f819b47mr2558823qvb.45.1697726551913; Thu, 19 Oct 2023 07:42:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697726551; cv=pass; d=google.com; s=arc-20160816; b=Fmq+FH3suE7GVG/CqsnDrVtWvgtHjEzYQkRqasCMALcsG9HoW2RrqJZ/UhOlXR8m8F Sk3vx0MhBMKzsz0cDkJe0jjHfsRS6z5XW/Zzk+j9YJ6Jjl8/MdFc3op/0eAmBPPZ3D9F xKoKPZPZHvkjt9QVoQL3hSorp/rKm2vTCuN2tcWaXnhxwoTcBQU+WUMQCxhuydn63Ioj Y1iDLHkKw+z0UbCK/sc3fwKUON0cfVd7XWdRZEW/PRE3e44JaOhFwgRo25LEHXPlyOrf NrphpJ11FvU1KYRLKwFJLTmN/Oyt24OJ3nQmGoNVjTj+9f+PP5HZAkkbfdRJWthQITgW eVqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=wuU4+JexJox3KzP2xv1qMqk4kEHnVFktoOP8HZnEdZM=; fh=/LGSvS9fKr8xUSOarN/hPHAOWzvFwgUy+6Y4FjnH2j4=; b=g1GBHq3GpREinAe10hkgoJNJCh/zBhl6WycbIAt2HKvQEfHA0dGNiBKf6WbZAMfriv 2To0gptSAjzP+n7SXw2AT/rTYFqN0G/VEou7qDVD9p1NYklOZjZ9gIjIhtxFjWW48LCQ 31Bwr6/oQJhqWk6+sm6obf7tYynhBfS3Ga7qPSzooBKNkwAkfknck7//dGYpAiEgsZfE N9zkEF9dB5HdHEE/LLWhX3nhaWkR8VOl6e2VSPJp5Vi/6T1UZlR0MJQGiTDPViroCPpT M+FNtk/W6x5mbrpkRzjLtxSLhQ4nAwo1yAbS2aB4E94YCfrcet2cs1Dq2SpAQFmMbpqZ Rx7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=V8Au4Li4; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i5-20020ad44ba5000000b00658900baafasi1590397qvw.609.2023.10.19.07.42.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:42:31 -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=@adacore.com header.s=google header.b=V8Au4Li4; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D1073853513 for ; Thu, 19 Oct 2023 14:42:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 185E53858C2F for ; Thu, 19 Oct 2023 14:41:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 185E53858C2F Authentication-Results: sourceware.org; dmarc=pass (p=none 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 185E53858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697726518; cv=none; b=rNsNer7Wc+zuvpio18gynlB2ucFCPB85WS0lLF/hqMSH0r4fhNLY5TUahw+gK4Y0uDHDw9LnopAIojvEkAcX0qQft0vVO1JPUU7YP/lRoj8sJ9+K01/Dgj0JOjygo/PyXYzqRQq801MID3UozqjZsroupFeKVNSV/mOK4AUWefE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697726518; c=relaxed/simple; bh=wCYtFQQ2ueqw9uWE0UOT+jBNeNG09XOwQYJ7RF0WU7M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RiPCl10IS3p5gzZ9mfC98y5xDpvn6TUbRQ2a1jYdHdDoXpAIBoHxHmzR13vYRc8896bKmzJ+m8Epnd/Ndsui6sdcGVdD5dvql9/1CRExEfk6/Ia8CdTkoLFzizX5ZyS+QYSsqJk7hilY0YLa95FsReaoWYpCps7X+P7tdux6Oig= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c504a5e1deso103087101fa.2 for ; Thu, 19 Oct 2023 07:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1697726513; x=1698331313; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wuU4+JexJox3KzP2xv1qMqk4kEHnVFktoOP8HZnEdZM=; b=V8Au4Li4AilcznP6eMb9f47Va/frqRH2drkN06TWwVDCbucQgrkPvFNO489vA3e8Mn LOnw9VtJzpCqYOxURfhwZvy5S1DTt2bS/J6DZ2od3DMqGsYNL9NT50j4BHlQEmqg/TLJ s7LBAPpBn4+t0rB1xUwOGhZMpcwCFoDFEzEHnO5Nio/hdf6wQeQcBkWiVlWCVgW6QTcR BJnC4k0iHnPDyyWjdQ/odP41sB6dHtxAx79ELW0WytTKIVputTZzuCMWUPuZBlBDVrfK dHL2opoBsDQ7p7JU5zXkSjPEJfoouTElNalpSy+yWCMOBV9j6alCPnI+7WomjXZWTjxR Vp8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697726513; x=1698331313; 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=wuU4+JexJox3KzP2xv1qMqk4kEHnVFktoOP8HZnEdZM=; b=jjz6qTMb0mq2aBOh8WJ7Suzs+VoDtM1JfpmIIi3wimHBKzDzNliHSTsv7yV2O5KWKX OL6frEMhHO5flxOjtU+FD1J2mdYZTWeTXbZjBfJSeWxD9jK4859iFTvp+3SGOFI22paa NBRtr32X5e30PmTRKdVfc1vdNcMa050/0uN2GlxqktRR9dSxXP43ORfPufkiHCiA5b92 ODWrjcQlyqs2BqLoIoilhXoVTsukHOtf+qQ01koEUvtHgu/MXCeOyvAsBfQDgvnQe5/o eOPnusAgMCysOrMGoO+LpJnvMBO5vc2t4tKvEgnT+qtIOPwU2J+MBXFrZbs4xeqoyrOn rgng== X-Gm-Message-State: AOJu0YxgBuujycBt6CDLyZEd+vrie0kSt10gcRCYUfaDOGB7nlHAkYZT ArD4WBd1kooN1E03yQrD9QQQ3Uu4dYSq+pXI3egWMA== X-Received: by 2002:a05:6512:613:b0:507:c763:27b7 with SMTP id b19-20020a056512061300b00507c76327b7mr1688441lfe.40.1697726513422; Thu, 19 Oct 2023 07:41:53 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:b43b:dc95:363f:b759]) by smtp.gmail.com with ESMTPSA id p21-20020a05600c431500b004076f522058sm4544517wme.0.2023.10.19.07.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:41:52 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED] ada: Seize opportunity to reuse List_Length Date: Thu, 19 Oct 2023 16:41:50 +0200 Message-ID: <20231019144150.339469-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.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 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780195316966851556 X-GMAIL-MSGID: 1780195316966851556 From: Ronan Desplanques This patch is intended as a readability improvement. It doesn't change the behavior of the compiler. gcc/ada/ * sem_ch3.adb (Constrain_Array): Replace manual list length computation by call to List_Length. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch3.adb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index c79d323395f..e92b46fa6f6 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13809,7 +13809,7 @@ package body Sem_Ch3 is Suffix : Character) is C : constant Node_Id := Constraint (SI); - Number_Of_Constraints : Nat := 0; + Number_Of_Constraints : constant Nat := List_Length (Constraints (C)); Index : Node_Id; S, T : Entity_Id; Constraint_OK : Boolean := True; @@ -13835,12 +13835,6 @@ package body Sem_Ch3 is Constraint_OK := False; else - S := First (Constraints (C)); - while Present (S) loop - Number_Of_Constraints := Number_Of_Constraints + 1; - Next (S); - end loop; - -- In either case, the index constraint must provide a discrete -- range for each index of the array type and the type of each -- discrete range must be the same as that of the corresponding