From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 7AA633861859 for ; Tue, 19 Dec 2023 14:31:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AA633861859 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 7AA633861859 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996267; cv=none; b=M4dDVzimaTftr9oEdE1/x2ApeR37LtYk+Y6uwcZB/M6SlV194/RHZqg9H5ohHEw+BTHJ9R9B/D1jWZFCABlbv+IXd7usdQPVZkRigBMvKZiaoSqHjUoPfOzkIrZLTcpYkk5i1U+6lljjjdg7WCQhvESsSnJ9V9TEEVVpNOaSH6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996267; c=relaxed/simple; bh=8ryyy1BlEU9io7tpvjZpGKESaPpbex+VIS/eDmEXIzw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TNFQov70GeXQuZF9Fml8ZNKCO0F2AlssopLodc7tkM05J+pom0AYrNtbzgrOTLt8n14GhXz8US2NgzI9Kg6jukYXRyzY30ASosG0v+jCjObDLcGaCJdwZqu3CydS4O83nKpB0HBihNFuTNq/JFCQl23ecMJ8WX6aR+tBMD6KQcw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40c38de1ee4so46219755e9.0 for ; Tue, 19 Dec 2023 06:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702996264; x=1703601064; 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=qspcPr7kYkITS1vyT1WqH3rcHgqr4Mh8rlBhnXR+1dQ=; b=gKszmGpC6mb5JMBiVslqCr/iyNtyH9HfhLMlgVLpYuuxTi/fmkLosY5ZjgGB1n/q7u XEf1z+tllC2Ex7oNDwX77JzxzwJwcUp7lUHa7+M/1kad31nTjFn8DdWAEnbb+fBYjDDH l/l6W6Mrd3fONaONYkF3S3TfbDOso3thHWD6KH5WScgoeUpFFUVso5hHy/Wao6SR8UYN kQ6Z06/Z5Tf3k73tk5y1Y/iIeDFH8yZTlrX7+k34OgSV4kgbipbqZtsjzk84x0EHzusu nabFy+uEhSN148v5tY4FNlLG5mYZ0HEEqEMthWErR/MA4eNIvzuUxR+UJU3l5KMcELwu 3AuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702996264; x=1703601064; 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=qspcPr7kYkITS1vyT1WqH3rcHgqr4Mh8rlBhnXR+1dQ=; b=SCMmBR84EADPGH/3si9+Lnj8pDL4ANc7iVdbpoClHxKJBU5eB1JNuutB42FEvRWuOC gYee3Wr5KY2qerz5Z9pt2lY9s1rpAdORe3K23U7gsHaG9XQh7txihhmgi4+CpeWf2LUH a92valfRXdGzC7pQfUE/NNZ8F+O/dG8Sx4kAi3C95kLaaSGM+0uLmJkaE8OT3SE1+SVD CwudIlH9czGKHPBxd5GbwAOhj4V1eZxQp4I4Lm2oLAFW+hMsQz04k7KTSK1nwGWWuok3 xMK+nHH3uCDM0cLMs6QPQVP4jD6ekWVrlciRUW/Ck2sAHOOwDEaOoPtircSS09+78RPa oWaQ== X-Gm-Message-State: AOJu0Yx/KCD8iGFbQKrPb8Wz4lgLjKtmJeW61OEDBNPWbrCyTJIo68dz QBVwLeOXPYotFQmFUOE4TGFsoMyPcVsyOUgB068= X-Google-Smtp-Source: AGHT+IHp4ZzUybmrMkCMhCEbXLcvx1GuRy73nkfZtAR7XX3yW5KCZU11GYeCzutgCdVNp9Bu2tL+kQ== X-Received: by 2002:a05:600c:3410:b0:407:3b6d:b561 with SMTP id y16-20020a05600c341000b004073b6db561mr9299419wmp.9.1702996264370; Tue, 19 Dec 2023 06:31:04 -0800 (PST) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:fe1e:443:c34f:edaa]) by smtp.gmail.com with ESMTPSA id bd8-20020a05600c1f0800b0040c44b4a282sm3090901wmb.43.2023.12.19.06.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:31:04 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Sheri Bernstein Subject: [COMMITTED] ada: Remove GNATcheck violations Date: Tue, 19 Dec 2023 15:31:03 +0100 Message-ID: <20231219143103.455945-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 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 List-Id: From: Sheri Bernstein Remove GNATcheck violations by refactoring code and also using pragma Annotate to exempt them. gcc/ada/ * libgnat/a-comlin.adb (Argument_Count): Rewrite code so there is only one return, to remove Improper_Returns violation. (Command_Name): Add pragma to exempt Improper_Returns violation. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/a-comlin.adb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gcc/ada/libgnat/a-comlin.adb b/gcc/ada/libgnat/a-comlin.adb index b95ecd3290c..8a6686181bd 100644 --- a/gcc/ada/libgnat/a-comlin.adb +++ b/gcc/ada/libgnat/a-comlin.adb @@ -77,16 +77,11 @@ package body Ada.Command_Line is function Argument_Count return Natural is begin - if not Initialized then - -- RM A.15 (11) - return 0; - end if; - - if Remove_Args = null then - return Arg_Count - 1; - else - return Remove_Count; - end if; + return + (if not Initialized then 0 -- RM A.15 (11) + elsif Remove_Args = null then Arg_Count - 1 + else Remove_Count + ); end Argument_Count; ----------------- @@ -107,6 +102,8 @@ package body Ada.Command_Line is function Command_Name return String is begin + pragma Annotate (Gnatcheck, Exempt_On, "Improper_Returns", + "early returns for performance"); if not Initialized then return ""; end if; @@ -118,6 +115,7 @@ package body Ada.Command_Line is Fill_Arg (Arg'Address, 0); return Arg; end; + pragma Annotate (Gnatcheck, Exempt_Off, "Improper_Returns"); end Command_Name; end Ada.Command_Line; -- 2.43.0