From patchwork Thu Nov 30 10:18:47 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: 81007 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 3C0CB38618E0 for ; Thu, 30 Nov 2023 10:19:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id A5931385840E for ; Thu, 30 Nov 2023 10:19:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5931385840E 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 A5931385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701339544; cv=none; b=RrFBwNErDNo7RU43vtFe4/BB3fVdwxPJuZTPxxrQktbt9swDN/EDpVE2mYwYgyOIoIYShBuxCqgprcxpWFd5pzghguQKs3Gw419ux9LoNOX32Yy4jZvna633fl7LbRzvdJkAEFss6PMNf3PPreYigq5OV1eaAQyiCUie6gXxiyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701339544; c=relaxed/simple; bh=JwRzdjzSkFtqHQYvyHVwZmxfJgxgfHXE9Bnhp+L12wo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TaweqdkcpZGaEjWW0L0EdICHBSTuqrz20FCzttH1Uigdp9uO/dpTraom91dT9QWIUHcRuezOwFjNAhxntJUo86LvPBKOqPgEhxKcUvAyeZf8SMSZzHXYoC8x2rrRh7heqkOY/Ll1MSbRAlLh9AVg47cUREpIdCjxau1U6LjddGk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4079ed65582so6199465e9.1 for ; Thu, 30 Nov 2023 02:19:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701339540; x=1701944340; 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=d0y+hQKxZnrZfZocHvoC87LZXtxpd62+N92sh7iKv7E=; b=NFefUWzkhV90sAC3ocYdJiKhOZZn8fSSBHv81PmAFCODu9I5wbdIVXQp2r4da61E54 bRN/jOpQj4SIfdUbc7suJJaL+uzRFfxKPaXgvMEgyTCPM1zKJEWzj5m+ChDISIa8yqmB I0qJkTyg8bpRJSvl9R8eBvrGJK2AELhmie+AdrK3YSsr3g0KBZwzTWxr7ev4AZluzna0 E3Q7g5L3Xcolo6ix2KTeaqiV+1RwVdLgqG8BLgi96o28dEz69nyOjJf+UXm1ORQjyi5y idjIpoY7uUghWPMFmR/Mb5LyKvrljtNOK8/8I/tBU0M5p7pyDa9mNX/rJxSBBXEeibXi 1JfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339540; x=1701944340; 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=d0y+hQKxZnrZfZocHvoC87LZXtxpd62+N92sh7iKv7E=; b=JmP5SoLj27wbmQKCNmyosy+i2Nsgmp5fAnvA4BwlXoEb3TH9rysTdof3lfB+VbGiG3 hiryUU4It9iQT7SP8l6vIYLNv8rjvilqMgqbSgCCwHCrpFhGWjZXRKg4Lb54qv6UfzNf Repxlr0eDSE9F4NByLzNW/4J4xx6SkWP/x+jUVMLhZY500aFL9Vhi34mt1rx+Oze0DtS mom7T3SbehokoU0t//jacYl4teW/meT/Hv9WkHSNdClRlSG8wqPb36I1awD50D2ku0EW BybUEucbv4gVAEQtwmyf80hviVPv4vsaxZQuM0hs2BKuQHN4QmtcUNID347cwC82lyfJ M2vA== X-Gm-Message-State: AOJu0YxHPDHJcd7xxKdlcdEnSOsu2RuJhBFOmG4NQMpzcjTG8YEJnGhx SKTd2ovP/n8nQL5+OfXlaj830eHPbhpwoZswTrKQpw== X-Google-Smtp-Source: AGHT+IGfyOY5k9Y0RCnSVKwnzNvQnvuRH/SNEFtQItsCjj7MGdhuWp/zvFhtEALqcP9VVnhVRXr+Ug== X-Received: by 2002:a05:600c:3ba8:b0:40b:36e6:b7ed with SMTP id n40-20020a05600c3ba800b0040b36e6b7edmr15373958wms.7.1701339540299; Thu, 30 Nov 2023 02:19:00 -0800 (PST) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id j35-20020a05600c1c2300b004076f522058sm5166072wms.0.2023.11.30.02.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:18:59 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED] ada: Constant_Indexing used when context requires a variable Date: Thu, 30 Nov 2023 11:18:47 +0100 Message-ID: <20231130101848.3093719-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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: Steve Baird In the case of a call with a formal parameter of mode other than "IN" where the corresponding actual parameter is a generalized indexing and the indexable container has both Constant_Indexing and Variable_Indexing aspects specified, the generalized indexing must be interpreted as a variable indexing, not as a constant indexing. In some cases involving a call to a prefixed view of a subprogram, this was not handled correctly. This error results in spurious compile-time error messages saying that the actual parameter in the call "must be a variable". gcc/ada/ * sem_ch4.adb (Constant_Indexing_OK): As a temporary stopgap, return False in the case of an unanalyzed prefixed-view call. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 83705b9dae1..d506944bc8d 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -8473,9 +8473,21 @@ package body Sem_Ch4 is -- resolution does not depend on the type of the parameter that -- includes the indexing operation. - elsif Nkind (Parent (Par)) in N_Subprogram_Call - and then Is_Entity_Name (Name (Parent (Par))) - then + elsif Nkind (Parent (Par)) in N_Subprogram_Call then + + if not Is_Entity_Name (Name (Parent (Par))) then + + -- ??? We don't know what to do with an N_Selected_Component + -- node for a prefixed-notation call to AA.BB where AA's + -- type is known, but BB has not yet been resolved. In that + -- case, the preceding Is_Entity_Name call returns False. + -- Incorrectly returning False here will usually work + -- better than incorrectly returning True, so that's what + -- we do for now. + + return False; + end if; + declare Proc : Entity_Id;