From patchwork Tue Nov 28 09:39: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: 80900 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 458C7395383F for ; Tue, 28 Nov 2023 09:40:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id AFED23947C31 for ; Tue, 28 Nov 2023 09:39:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFED23947C31 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 AFED23947C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701164401; cv=none; b=SenqoAIwUVYCYHGZ0zPpqbvCyKSKHclOTtfCWVm8PEVf63IKITTDBso1UFIYRQAgsL4eaGchrhcb3dc2YJSVTnl6DQ+knG67aNmGjm1ea157MXwk8PGQ1WKSCOErYs/IPTZlJ0P/B7z5BUQRBsFgj39fpLZq+7VRDYZdvHRojUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701164401; c=relaxed/simple; bh=J4IVBcwzd3Hqt2L73T4g9i0hnvj5FC3UK+oV8fHh9To=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Z9zkTV36n3zpD0jitYUnckmG3QTHhEWm+QIj3FOvDWVJjNEu+DksDljGGDH3d8QoKG247kMDHgkkRfL/zCBgCQAH/45Cw/A9rdHsDZv6qq8c44hfYm7RNAT8NJfW7lM30eqQ2uLAqEgpFUd2acKLK2FnT6hsrFTx2SgJG9hUDKg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1cf80a7be0aso44701855ad.1 for ; Tue, 28 Nov 2023 01:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701164399; x=1701769199; 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=SdfrisgUBpARrliGon8/AVfwJh8kgePIH0eHtb7Gje0=; b=ctE/wqeMQVA5lLeMB+7LL1qAi/cDPo2cyUMrJKqOXMkkF4w8Hw+33LJHWljC7fkgto hVMP6u4YoAiRhn6nI9oSGX0QI2diDBHs/06U3bHYBfO82mMr6oZkIRlYZXzz5995hShL psosO3W5dTsHHZtfQiP7tPjMlF4RrxaqTG6fAWlVeLnmaM0Evkr7tii8JAee5K/aWPqL 5e+132ybkhCiCBv01RHP5YpmY+YVEcUX5edPkv27gEa+bc9+/4SVaZ6e+JXyR0yRyWkP 5iYqnppzMpi39eDYefJNbn3dGSBON0BS9RAMUagqgBgG7p5mTfZwkv7rLmcaHi0gFvCl I+nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701164399; x=1701769199; 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=SdfrisgUBpARrliGon8/AVfwJh8kgePIH0eHtb7Gje0=; b=Rj8EshAVLNKm+fcJJRkGGg7Ha0mjODsvw8bC2Rtd9O6q98gv5Twyydi8d7MLJpHLe6 d+FCdiboHXtE2RvP5qN579nceB/3MFuKMQo4tz4rMpC6GVoDSpU6kHlY1oyN0oFRn/Ld COa8mLzvOyAj7z1t0AQJZcHhMawF6L3oqk8Z/V86CxmpZ0Akbt0bGsIFcpFH8FX8qSnW f8LaMEplg3XDC/gSgGCGmElRvMNu9RoKHRNVePg+BkqDyAve+tUJoz9CX053N1y0wkxA Afi0xpwdOE4zdDShVShlWpYX7OgZDVJA+rI3wDocyH1BIwcIQWHsCx2nLP9h35cryw5z 6zVA== X-Gm-Message-State: AOJu0YyuU4Pj5SVh+HMdG4ioAXsbbYqy/6pUzzoPGJ/i2czYD9vmLOfY he3LKgw/JkjY3vcu+giXpYNYxS2hq7FX7B8lgf2aUg== X-Google-Smtp-Source: AGHT+IHoF2iB7qAx6SRY0SxwjGxeWpXyDGj057ocBUaLPTcNN7R1O1xy/77SFBE5roPanpu+nEUqOg== X-Received: by 2002:a17:902:d303:b0:1cc:4e81:36a4 with SMTP id b3-20020a170902d30300b001cc4e8136a4mr16969536plc.5.1701164398816; Tue, 28 Nov 2023 01:39:58 -0800 (PST) Received: from localhost.localdomain ([2001:861:3382:1a90:a24b:a65f:9576:c701]) by smtp.gmail.com with ESMTPSA id jl23-20020a170903135700b001ca4c20003dsm9753235plb.69.2023.11.28.01.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:39:58 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED] ada: False alarms from -gnatw.t with generic functions Date: Tue, 28 Nov 2023 10:39:50 +0100 Message-ID: <20231128093950.2971184-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 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 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+patchwork=sourceware.org@gcc.gnu.org From: Bob Duff Disable the warnings generated by -gnatw.t on instances. Otherwise, we get false positives. gcc/ada/ * sem_util.adb (Check_Result_And_Post_State): Disable this when we're in an instance. Misc cleanup. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 423b8d3f936..9215fc7da6c 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -4370,21 +4370,24 @@ package body Sem_Util is and then Has_No_Output (Subp_Id)) and then not Is_Wrapper (Subp_Id) then - if Pragma_Name (Prag) = Name_Contract_Cases then - Error_Msg_NE (Adjust_Message - ("contract case does not check the outcome of calling " - & "&?.t?"), Expr, Subp_Id); - - elsif Pragma_Name (Prag) = Name_Refined_Post then - Error_Msg_NE (Adjust_Message - ("refined postcondition does not check the outcome of " - & "calling &?.t?"), Err_Node, Subp_Id); - - else - Error_Msg_NE (Adjust_Message - ("postcondition does not check the outcome of calling " - & "&?.t?"), Err_Node, Subp_Id); - end if; + case Pragma_Name (Prag) is + when Name_Contract_Cases => + Error_Msg_NE (Adjust_Message + ("contract case does not check the outcome of calling " + & "&?.t?"), Expr, Subp_Id); + + when Name_Refined_Post => + Error_Msg_NE (Adjust_Message + ("refined postcondition does not check the outcome of " + & "calling &?.t?"), Err_Node, Subp_Id); + + when Name_Postcondition => + Error_Msg_NE (Adjust_Message + ("postcondition does not check the outcome of calling " + & "&?.t?"), Err_Node, Subp_Id); + + when others => pragma Assert (False); + end case; end if; end Check_Conjunct; @@ -4555,11 +4558,16 @@ package body Sem_Util is -- Start of processing for Check_Result_And_Post_State begin + -- Do not check in instances, because we already checked the generic + + if In_Instance then + return; + -- The lack of attribute 'Result or a post-state is classified as a -- suspicious contract. Do not perform the check if the corresponding - -- swich is not set. + -- switch is not set. - if not Warn_On_Suspicious_Contract then + elsif not Warn_On_Suspicious_Contract then return; -- Nothing to do if there is no contract