From patchwork Wed May 18 08:43:08 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: 54128 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 1A7F93857822 for ; Wed, 18 May 2022 08:50:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A7F93857822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652863849; bh=eNBE1xHS8jAqD3rilSBxQQvENYylKF4q/TZM9kr8fjM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aIPXI/owwy34mfrAwaLRn5Sp3Pf+oKL2G6YuJIfkAM/jcHxy04NtaIMn+20sdzNus GrwFu0kU5iifbfBfYH4fMWyBvAqYidZHf4lFt+mJU+FJduYDeoIhFW++qpWAIP/FF5 7YGXfnpef38CwJV5UWelQRpJHIkrJTxqYk0QSWS4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 783F53857823 for ; Wed, 18 May 2022 08:43:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 783F53857823 Received: by mail-wr1-x42b.google.com with SMTP id t6so1648225wra.4 for ; Wed, 18 May 2022 01:43:10 -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=eNBE1xHS8jAqD3rilSBxQQvENYylKF4q/TZM9kr8fjM=; b=nElG39wP+IZqm/zAgGfj5g3jA6iZe6Zxr1d9GYwxIbIl5OD1gCC/wJW6b9oYQX8n7M 2XD918m/IzUZcWRBzn4vsFR/T5KrEy8yRwyDTnYVB7UJDPg/WycMpY5NxJ1MrfyqfcPC U3Q15ch9bO1kwzFJJAcVvQJLNZU5h3KZTf+9narou6z9rE7Q876rR6MgxXyf7/gJtKco P+160ZoA3ZS7wHCIshUwA10EfHqmDwKmJQQ8XXNGyC2LJe7oAx8yQEBE1byyTA5PG/wF SnsEVE0JAH4T+gVoFBwSTTtUFsxjug6P3QREiUUbIAfeYfqtnRTRQO489nYIBLZnnJCF +4WA== X-Gm-Message-State: AOAM531RfsdzAJOUno8a6Bc3ardICK6KP+K5zYQQe0o7tHClehnfcF81 MVTfKqAmp010CkOh+roT81C8PthEaB/A7g== X-Google-Smtp-Source: ABdhPJx/BSmWOdMlPUxZ8Pujr6fVC8V1yIlWJA/YqLKK8KD3WnvYcgTZ7+X1836OFx2BW8xh7GlR1Q== X-Received: by 2002:adf:f00c:0:b0:20d:12c3:dfae with SMTP id j12-20020adff00c000000b0020d12c3dfaemr8345250wro.610.1652863389185; Wed, 18 May 2022 01:43:09 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id h24-20020adfaa98000000b0020d0a070c80sm1358620wrc.35.2022.05.18.01.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 01:43:08 -0700 (PDT) Date: Wed, 18 May 2022 08:43:08 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Overriding error on type derived from discriminated untagged private type Message-ID: <20220518084308.GA3311250@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: Gary Dismukes Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" When a derived type DT has an untagged private parent type PT with a discriminant, where the full type of PT is tagged, and DT inherits a function F with an anonymous access result that designates the type, the compiler wrongly reports an error saying that DT must be declared abstract or F overridden. A test is added to exclude checking the abstract overriding rules that should only apply to inherited subprograms of tagged derived types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Check_Abstract_Overriding): If the type is derived from an untagged type, then don't perform any of the abstract overriding error checks. diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -11047,6 +11047,14 @@ package body Sem_Ch3 is Subp := Node (Elmt); Alias_Subp := Alias (Subp); + -- If the parent type is untagged, then no overriding error checks + -- are needed (such as in the case of an implicit full type for + -- a derived type whose parent is an untagged private type with + -- a tagged full type). + + if not Is_Tagged_Type (Etype (T)) then + null; + -- Inherited subprograms are identified by the fact that they do not -- come from source, and the associated source location is the -- location of the first subtype of the derived type. @@ -11065,7 +11073,7 @@ package body Sem_Ch3 is -- overriding in Ada 2005, but wrappers need to be built for them -- (see exp_ch3, Build_Controlling_Function_Wrappers). - if Is_Null_Extension (T) + elsif Is_Null_Extension (T) and then Has_Controlling_Result (Subp) and then Ada_Version >= Ada_2005 and then Present (Alias_Subp)