From patchwork Fri May 13 08:07: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: 1630573 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=Q3VIrkUj; 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 4L01rh6kRLz9sG0 for ; Fri, 13 May 2022 18:24:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94A46384B0C8 for ; Fri, 13 May 2022 08:24:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94A46384B0C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652430242; bh=FTfRMqwdRK1i9DsAZ+VsA9caPGunrNyM9PVJ648GRK0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Q3VIrkUjJOcckkS7woDNmu763j0RrXbb7mFiynLtB0AiIccdRIAApSFuGJRKWAiib vHx+1xwSOF6iKzUr5/zGci72MR+UsOVNzxOwNlBsT+uhJVWltSWrTjEnY78Nz4qS65 M6Gyal90V2JTCNbIs43DOvqshLPGDy8ETjSx01Fs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id BA9EF384F02A for ; Fri, 13 May 2022 08:07:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA9EF384F02A Received: by mail-wm1-x335.google.com with SMTP id i20-20020a05600c355400b0039456976dcaso4867597wmq.1 for ; Fri, 13 May 2022 01:07:46 -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=FTfRMqwdRK1i9DsAZ+VsA9caPGunrNyM9PVJ648GRK0=; b=6HWRoTlC0zp/ChJHfcuIXrtkyUze2uJpMXevaQU7ZxmjwVemiHwFHBERtXhBTpqv10 EqQoAgbdfjewwWlrE2N3JkFK8RsJt84nD4sqESNPCPZ22XXiOHKlWSAXD2fhJL9WIodt z/07SFE5tCyn22nQNP9i+pOUW+8w0NbW3e/mpJN9HU3tALCkWQqwY3cRb0kjMNZqk5ms WlSB9PorGmvXhHn+o+vaAc4Icxt/M6fDDGr0lSxvluXHexviXEhVU4P47DmZjQ4XP9CP JXP4ju/ySf9U9SGNtdRUcdE/dEb+rSlHDGpXAlXEgtY+QVMOn857/6SQosOi8XrxTQxT 6Atw== X-Gm-Message-State: AOAM5314ZIhSoAeBi4Jek9xVRKKsJCm7bU9y3QdKZDIPQNQti0OVsU1m DzR/0MjUDXuojqP8Nsf9cgxMB5g3ViiUpA== X-Google-Smtp-Source: ABdhPJzUdCgbbwEwS2G+Uos+S4LfN+Uhj0PxgGjGFAvsVv8c5CvX7xI7czneBe4oFXQf4jmkM/Yi8w== X-Received: by 2002:a05:600c:600d:b0:394:5353:507a with SMTP id az13-20020a05600c600d00b003945353507amr3423118wmb.96.1652429265531; Fri, 13 May 2022 01:07:45 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id z23-20020a1c4c17000000b0039456fb80b3sm4581066wmf.43.2022.05.13.01.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 01:07:45 -0700 (PDT) Date: Fri, 13 May 2022 08:07:44 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Handle IN iterator for class-wide derived object of iterator type Message-ID: <20220513080744.GA2512046@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: Ed Schonberg Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The compiler currently rejects iterating on an interface type derived from an iterator type. See Ada RM 5.5.1(6/3) and 5.5.2(3/3). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Analyze_Iterator_Specification): Fix Typ in the case of a class-wide derived iterator. diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2761,9 +2761,21 @@ package body Sem_Ch5 is end; end if; - -- IN iterator, domain is a range, or a call to Iterate function + -- IN iterator, domain is a range, a call to Iterate function, + -- or an object/actual parameter of an iterator type. else + -- If the type of the name is class-wide and its root type is a + -- derived type, the primitive operations (First, Next, etc.) are + -- those inherited by its specific type. Calls to these primitives + -- will be dispatching. + + if Is_Class_Wide_Type (Typ) + and then Is_Derived_Type (Etype (Typ)) + then + Typ := Etype (Typ); + end if; + -- For an iteration of the form IN, the name must denote an -- iterator, typically the result of a call to Iterate. Give a -- useful error message when the name is a container by itself.