From patchwork Mon Sep 12 08:19:23 2022 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: 1144 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1780722wrt; Mon, 12 Sep 2022 01:27:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4/5JxfPUTK0fp5TMg1V043xV4Spiq+skhvFiV9UCStDRTV9yfCiJ+BkrbFP8PsPhcOWR44 X-Received: by 2002:a17:906:8477:b0:77d:185a:b443 with SMTP id hx23-20020a170906847700b0077d185ab443mr3301026ejc.311.1662971257345; Mon, 12 Sep 2022 01:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662971257; cv=none; d=google.com; s=arc-20160816; b=oBYsly5/4Qz4hRH/e8BEVJATaFvpLwExicaMsKPQpmuEr05Rigi/hGHc6y4H79ojM+ WiazNw2Ls3ay1K5viQ+E1JtYcbtvxDb/AMo9utHitnKvpmMjClvT9X16V/K0whUD0pdg TvZq0/0ECa6Ie439Xust07vTrbxwDD3eo0AMSn3J40ajndiM287Q+zWrEOqmZJA/vAFL 9qpm7PQstAR/RJe/2EgbQOSzEWsbzsBIXmpG9CoPIcRw7Luahr9i3fE4Tivxvzsl4u8Z PxN4MnvmO5Aw66BtQPtWTO8rYSbn3V4uTgv34uRW47fsPJbhvj9UR6qjb5EGHB9Cx0ya 2jDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=lKPkripIGVPLNRIxfhSth04XzUqZf8jklX4iMzlA4vI=; b=xIuDzB1MVGQW/4Y1/+SJ3RySCbHWBNcWtNXp+lEOxQG1+D7vo5gnrfxgVprkVPCDzB 6+NG4P4SOWeKOJQ+Rwmsp8hrJvappGqTBQOMToh5jU2sP5qJcHVOz/zfhON2HX9QDt7F oMbqURcDuvUvejOm3gRf128HjdkUXHQXDxhaWucjrLQOG0dJBXqxWdTb4z+vlQS2p+Rn blEZYsD37O1a5OrzUcOl9lnYyCyBMQU8cNC4PISeWwFxJHYIdpBmqA+zEQwLiJnnMZnV P+nIis3q29yr5e91FnzCRKW7JHi1HsyJJ6SHdKREDHQKR/HkzLDxnjUoLa+dLCsyuRXD 61qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=B4aHLAAc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k21-20020a17090632d500b00774799ee7f8si5989451ejk.913.2022.09.12.01.27.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:27:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=B4aHLAAc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7FAA38A8167 for ; Mon, 12 Sep 2022 08:23:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7FAA38A8167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662970985; bh=lKPkripIGVPLNRIxfhSth04XzUqZf8jklX4iMzlA4vI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=B4aHLAAcZ961wL82ufAj4MqkN07uMvzv0rN0qxCkk9arpMXZ+v7sdhMdXgS828h/m wK7BH9rd/Cb0PNZqtrgECAXYozkR5FZUQ7JtWIoSI4Nies9M4yvf3jmKh5POTQKjn+ p7LE7E5jXSsXcKyZQJw2gtQvWzvkVFZpZM1oM1Nw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 70F273851ABF for ; Mon, 12 Sep 2022 08:19:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70F273851ABF Received: by mail-wr1-x42e.google.com with SMTP id d2so14085455wrn.1 for ; Mon, 12 Sep 2022 01:19:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=lKPkripIGVPLNRIxfhSth04XzUqZf8jklX4iMzlA4vI=; b=tdFIx9wmiurfDQWj1Cx1Ycys/Jsj1Sda7Y3YspWWuiFKLDdk9w9nY15OHg2RKGoTtr EA0wkv8Vglmkc6mM5axZ7bMQ5qTCbZnVj2epuU9T9SP8ZSAu+lobPbJVn0hl069geWpZ ebgE0spfGxVjyjcQL8zpa6XxmEjuInCCdlzMOck61ZgX60h5t/0SGKO7ISlgWeUurqBp nKI7NbQAOBE9jg/UY2H7+d0A3jEFEAXoymtkbIX34qhNoub9t/2pExzUyiOu3rFhSQY4 KmNB9OHTahTLeP3UaG8cvoJbYmknn38ETjWj5Uhv6V7I3xdKLq3qzsX+nqdAKaBbLou+ uCRg== X-Gm-Message-State: ACgBeo1fFZrf8l7GDbirw5+HEeg6OL/op4yEP6sneKIcon+DTV2CUnsh xfAJFXgaFuedll+hx+4oIIqtaAvi6Yq3oA== X-Received: by 2002:a5d:5310:0:b0:22a:3960:b405 with SMTP id e16-20020a5d5310000000b0022a3960b405mr9062795wrv.235.1662970764122; Mon, 12 Sep 2022 01:19:24 -0700 (PDT) Received: from poulhies-Precision-5550 (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id l4-20020a05600c47c400b003a541d893desm8518278wmo.38.2022.09.12.01.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:19:23 -0700 (PDT) Date: Mon, 12 Sep 2022 10:19:23 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] bugbox referencing INOX prefixed view of primitive op of modular type Message-ID: <20220912081923.GA1512890@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Steve Baird Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743751748941006794?= X-GMAIL-MSGID: =?utf-8?q?1743751748941006794?= The -gnatX switch enables naming a prefixed view of a subprogram with an untagged prefix. Compiling such a reference where the prefix is of a modular type could result in an internal compiler error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Avoid initializing the local variable Comp if the variable is not going to be subsequently referenced. This is a correctness issue because the call to First_Entity can fail. diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5187,7 +5187,16 @@ package body Sem_Ch4 is and then not Is_Derived_Type (Prefix_Type) and then Is_Entity_Name (Name); - Comp := First_Entity (Type_To_Use); + -- Avoid initializing Comp if that initialization is not needed + -- (and, more importantly, if the call to First_Entity could fail). + + if Has_Discriminants (Type_To_Use) + or else Is_Record_Type (Type_To_Use) + or else Is_Private_Type (Type_To_Use) + or else Is_Concurrent_Type (Type_To_Use) + then + Comp := First_Entity (Type_To_Use); + end if; -- If the selector has an original discriminant, the node appears in -- an instance. Replace the discriminant with the corresponding one