From patchwork Thu May 12 12:40:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1630180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=CfcCRIkS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KzX4M5rtxz9sGF for ; Thu, 12 May 2022 23:02:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 779733839C71 for ; Thu, 12 May 2022 13:02:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 779733839C71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652360545; bh=+/zR0MMHlNCvMMvM2HSRQA7t9In/0gbJbdpv8+ENeFk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CfcCRIkSJyEtdriYvTswQXYLOtR3i3vM5oRxbGxRFXzh2PYZOs2Uelk1QgK26e9tU LYsMLLauRv5HmquqB/lNnCM5L2d+7XLIKpZvPAK9cWvJN+c1QBz7hh2YKhw0OUhMIN Ky8aXzMBC3shuaMs/EshTeea/cUh76XrayF9v/cM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id E6A24383D815 for ; Thu, 12 May 2022 12:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E6A24383D815 Received: by mail-wr1-x436.google.com with SMTP id d5so7082272wrb.6 for ; Thu, 12 May 2022 05:40:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=+/zR0MMHlNCvMMvM2HSRQA7t9In/0gbJbdpv8+ENeFk=; b=AM3+WC7DcR2WtstsGJQcOoHrYkb8ktKYGTAKT3rLPm/G24SDg3uRgXCHd/knNjzdfT yLvF6JGrLn2V8TxpH3/J/rdjMUbJF9iwEP3CZyRMqbXoZR6ZW3D84T+Vqmx5PnAoBfjg Ioj36pptY7HtKK9NwoGacoZ9HlfAc9F9qd9Re0LwwBO4Cz2pUCO7nENJSgHhqZnBLcjL ti51N3mGAzY/6KaxVyaNaXvw+6SiN99a6uKDwa3qniy65KBb3BoNOm1wb7bsx238BCCU QUhrJMidfUrN26gb8wIHAWkYzw6SDT94xRIKraxw+s4m3tbsVS7k/TLgBtCOjea9V7fS IyWw== X-Gm-Message-State: AOAM533BOafrfTiKovdrMB492YA+zucWRg6z+S6lk15uUe3u7Ni6KAlX S1fq0+E8cjPJVcJmCPjexiX3TaZcfSJh+g== X-Google-Smtp-Source: ABdhPJy9YXGWwFmLbNZLzJJ2w7RWyhU93T8Gn2Zu/OH40gXwjo+zNU0zhj9FZRpzS34fB8DMmbTVOw== X-Received: by 2002:a5d:5281:0:b0:20c:d5be:331c with SMTP id c1-20020a5d5281000000b0020cd5be331cmr11289351wrv.9.1652359212539; Thu, 12 May 2022 05:40:12 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id o42-20020a05600c512a00b003942a244ed2sm3335454wms.23.2022.05.12.05.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 05:40:11 -0700 (PDT) Date: Thu, 12 May 2022 12:40:11 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix warning about generic subprograms withed but not referenced Message-ID: <20220512124011.GA781121@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" For warnings about unreferenced entities and unused WITH clauses we typically exclude references outside of the extended main source unit. However, we include references to variables of formal private types to warn in the instance if the corresponding type is not a fully initialized type. This special case was unnecessarily applied to references to other entities of formal private types. In particular, we applied it to the references to generic functions, where the full initialization of the formal private type doesn't matter. As an extreme example, this special case was unnecessarily applied to "pragma Pure (Unchecked_Conversion)" in the runtime unit. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-xref.adb (Generate_Reference): Fix comment and implement it precisely. diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -664,7 +664,7 @@ package body Lib.Xref is -- a default in an instance. -- We also set the referenced flag in a generic package that is not in - -- then main source unit, when the variable is of a formal private type, + -- the main source unit, when the object is of a formal private type, -- to warn in the instance if the corresponding type is not a fully -- initialized type. @@ -694,6 +694,7 @@ package body Lib.Xref is return; elsif Inside_A_Generic + and then Is_Object (E) and then Is_Generic_Type (Etype (E)) then Set_Referenced (E);