From patchwork Tue Jan 11 13:32:44 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: 1578510 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=pKMP1er4; 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 (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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYCJ526l2z9s9c for ; Wed, 12 Jan 2022 01:09:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1CC338A941D for ; Tue, 11 Jan 2022 14:09:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1CC338A941D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641910194; bh=GRA2VtIIKwW3nrz2yJHLHgCD7qt1pb/jOQRLXOs0+ls=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=pKMP1er4/AbhA2nRAIg5xkRm8gb0GLNuvEAs85H7jw5955yHHNUnJO4HkxYmSlZx4 6CSBWhbTkgPChN75a9tgsA5g8zN1ZX4zAcAMMTB3Ko3orD+Bcvix5KJ4aNv1pz1yRf ek7VDbapTi/Y2BTm8w42m58CPZQqq80/0gN1mxnQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id BEF5E38A9414 for ; Tue, 11 Jan 2022 13:32:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BEF5E38A9414 Received: by mail-wr1-x42f.google.com with SMTP id l25so22128278wrb.13 for ; Tue, 11 Jan 2022 05:32:46 -0800 (PST) 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=GRA2VtIIKwW3nrz2yJHLHgCD7qt1pb/jOQRLXOs0+ls=; b=wiWEKlxwgt0kMQoPad50TQBI/C5hwy5AdFutXbz9AwHgBdqudg2MC4YSGCYyYnxLlT riDWT6wkVJvuszv4nYdlTcWo9Ch1PyLvAz0fAclxqM9i+cUQS8GY2jhYcIeNvRua6fPq JgOqzVJczaqtJb0ngrgzDy8gqan/VWmn1D0sXx7A21jwsBSgE5xWFMC/KEOZAHNY0BJv yFJfWUlV/g+ERkPYT7yjwKtxb8w21onn5v6fHv+To/1V3nRzuUMGNpcD/hTpxEd+KSjw Bsl/5Xz3C1X4rQlBLTFSd3eW4gTMmVrTwVZ3rlLFeeGXSAu7KfU/RyzIyJts+hv/Rqv3 D8CA== X-Gm-Message-State: AOAM5315pjPe1cSMFO9hGWd3pAIlceZe0EbwQIuyj2ahJfVvndlB8Ex/ XdrzBB3/wAcFnI2jQMnYp+35zxwA0XHMvA== X-Google-Smtp-Source: ABdhPJxwb66Nfq4y3cKqAEadVa3thbWzVbR8cdBjIyu4hB5exkPOzX/OXpoYUEcRFp80uBXHmRxmSw== X-Received: by 2002:adf:d0cd:: with SMTP id z13mr3845166wrh.103.1641907965788; Tue, 11 Jan 2022 05:32:45 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id p18sm1940527wmq.23.2022.01.11.05.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 05:32:45 -0800 (PST) Date: Tue, 11 Jan 2022 13:32:44 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Include generic instance names in non-visible entity errors Message-ID: <20220111133244.GA749046@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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Justin Squirek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch adds the printing of generic instance names when encountering non-visible entities instead of just the line number of the package instantiation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Nvis_Messages): Add generic instance name to error message. diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -5689,8 +5689,27 @@ package body Sem_Ch8 is null; else - Error_Msg_N -- CODEFIX - ("non-visible declaration#!", N); + -- When the entity comes from a generic instance the + -- normal error message machinery will give the line + -- number of the generic package and the location of + -- the generic instance, but not the name of the + -- the instance. + + -- So, in order to give more descriptive error messages + -- in this case, we include the name of the generic + -- package. + + if Is_Generic_Instance (Scope (Ent)) then + Error_Msg_Name_1 := Chars (Scope (Ent)); + Error_Msg_N -- CODEFIX + ("non-visible declaration from %#!", N); + + -- Otherwise print the message normally + + else + Error_Msg_N -- CODEFIX + ("non-visible declaration#!", N); + end if; if Ekind (Scope (Ent)) /= E_Generic_Package then Found := True;