From patchwork Tue Jul 5 08:29:54 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: 1652343 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=beadTnNy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4LcbWk26Zhz9s1l for ; Tue, 5 Jul 2022 18:32:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 284A03833782 for ; Tue, 5 Jul 2022 08:32:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 284A03833782 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657009936; bh=mzJz3d+UsS81504u5/TEKvkGFu82bXZANh8guf5ln2A=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=beadTnNyHUMJe34MdBO3d5K/KJgh5FEXnRQQpbAXzk1Ltw6nHWqDhPzLLWiRb+Tvr KCTTtTht+XMw+u76/wU3i0xIWzI6l8+UoQr6p4abNr5oqJVpG1fNt3mfaoJgp/PjKT Wg5HGrTNwl/403oHDnsOx7ouFHQLXVqcmRUaLmwA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 1C881385E032 for ; Tue, 5 Jul 2022 08:29:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C881385E032 Received: by mail-wr1-x429.google.com with SMTP id q9so16426272wrd.8 for ; Tue, 05 Jul 2022 01:29:56 -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=mzJz3d+UsS81504u5/TEKvkGFu82bXZANh8guf5ln2A=; b=j4JfACBKzO6SeWxOfBSepDNhYn+Rr8JYMKFgkYjup/qjmIttwoWhhgg2zQ4vxVmgEi OxYllCIkf8RsHzhZaiPhZXge9QEuL4uaXPz2CqJ7XqD1wZ/m9UFIyB2xhSWPm27AIB3n FmPw6FQE9i43pIRiXuPgGWT7jXC5BXxabkKZiIejTGOznwVDan92/3zllN3fKd1zCZ0q La7PAxj11VVdqOgNLRrC0Xqqsm19vlKTX1sNebZL8doriR26HjpP59TwBJLa7eEecO9O D2ZTsJYchIDL7L/jNGgq/n5tZ+BBKklOKN/jjoGCb6EXIc+4Ju6n8GP4mCAzz/VWGVHV DgDQ== X-Gm-Message-State: AJIora/4ynAijhUQwSZJ8C8Kd2o8lG91FFrLzE5OvHk/l2Jv9P1Nz81p BfXVo6yXE2jDY6qDwXrkGWKVVbhFXt9XVw== X-Google-Smtp-Source: AGRyM1vd0VDWljRCAGZwV4qq4H+KdSSYTrVvxAmg2Ioivz66X8dDxiaopnY4jGQpnk+Yy8O99F34fw== X-Received: by 2002:a05:6000:1ac8:b0:21b:9236:6207 with SMTP id i8-20020a0560001ac800b0021b92366207mr30166212wry.123.1657009795711; Tue, 05 Jul 2022 01:29:55 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id y13-20020a5d620d000000b0021d4694fcaesm12203601wru.107.2022.07.05.01.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 01:29:55 -0700 (PDT) Date: Tue, 5 Jul 2022 08:29:54 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Spurious error on qualified prefix in Pack.Func'Result Message-ID: <20220705082954.GA3185056@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.3 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: Yannick Moy Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When using a qualified name such as Pack.Func as the prefix of a 'Result attribute reference, the prefix is not fully resolved and may contain a chain of homonyms. Look for the expected function in the homonym chain instead of issuing an error if the first one is not the expected one. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Analyze_Attribute): Take into account the possibility of homonyms. diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -5835,6 +5835,12 @@ package body Sem_Attr is elsif Present (Over_Id) and then Pref_Id = Over_Id then return True; + + -- When a qualified name is used for the prefix, homonyms may come + -- before the current function in the homonym chain. + + elsif Has_Homonym (Pref_Id) then + return Denote_Same_Function (Homonym (Pref_Id), Spec_Id); end if; -- Otherwise the prefix does not denote the related subprogram