Message ID | 20220902075330.GA1121091@poulhies-Precision-5550 |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp610753wro; Fri, 2 Sep 2022 00:55:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BBRMRCTmo8nQFzJ5Kfd75qDjrBP13rCdV0NcJpB5PIvTJvc5W0A/UhxpQBDIuw83By8/a X-Received: by 2002:a17:906:9b8b:b0:741:56d3:b8fc with SMTP id dd11-20020a1709069b8b00b0074156d3b8fcmr19493455ejc.337.1662105304046; Fri, 02 Sep 2022 00:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662105304; cv=none; d=google.com; s=arc-20160816; b=b47ZqEJGLxqDGdWQZ2Oosmzf96rmiaDJFIrjAFDcqGmuuGmLc8UAI0Qd6YmoCExJGr VhPMqEPuchrMrDKUBoKIJjszQ0gCtdFZD6HeVNCxdWE++ifP0mygfAwlMF2ytlywD1AV w/armr+5P0ILEC1WcFI99NJqTfXL47/I+tzCsipYY/C6h7JcjB5GnqPJLShqFMnCBoWP zXD+7B1XzEeURwbExKmeLOzCFkoJAwuAXZX0QoDkYEYJQPhJStrmoflQJi1em7xaitHi /LnFpHHrmMeVpDf1iagg8uHmsbMJC3g93uXS1CjaVeMMEgo502IcAIeXpmpInJacKF6F hySg== 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=qhBv5NS8P5nm38lsFLGvo8/8cFXpYRqXAAIh1tseZZ4=; b=ahRPfqFYK1TqmxoXsbuuIOY/mwN3Sh0TtXwqwYJo0amzAOmBtntfd/NGc0z915nWzZ ijVqzFP2218fAZMBEdoQHgO6uU0OmCynUYdyaEsc1GEo+IWh8k5RHXlu4xLtanSMoQ0N jY1LtVNm6l3pfpLJw9dblluoZZTT7t4VrQaAuTnFL/Li1UXpTVSbRGYKQ7T4g62+YaFi u3v0cmhJMRSYNkC4qsKJXSkUXPVghHnH7nuGAas3FTwdadPobFU6fkzQfNbhMsZnZH42 /ZpuVO0E3wOfYa0hie1l2pU7SVyB8C7/9TbY4Q5iiJP0TxTE4c02LTDkLVvRUZj8uAo4 9sqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XWlBtDci; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d11-20020a170906544b00b0073dda816423si1131290ejp.186.2022.09.02.00.55.03 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 00:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XWlBtDci; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 1C3703851147 for <ouuuleilei@gmail.com>; Fri, 2 Sep 2022 07:54:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C3703851147 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662105259; bh=qhBv5NS8P5nm38lsFLGvo8/8cFXpYRqXAAIh1tseZZ4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=XWlBtDciuEdLFrg48mXJqSySIFtT/AoyLUn8rhGsqTOW7u0rhe0inlRCPjTx6OjYC 1ZWQ6MshxZGlhcBSD9cHVJZwXcCz5G6c1hFSZPX+dVas0Ry4WfwOXRfhbZqdiPqR3Q +mdgrktpgGWFr2fDs/VbScaE0RZijd50gVfc/LWo= 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 252813858032 for <gcc-patches@gcc.gnu.org>; Fri, 2 Sep 2022 07:53:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 252813858032 Received: by mail-wm1-x334.google.com with SMTP id ay39-20020a05600c1e2700b003a5503a80cfso919130wmb.2 for <gcc-patches@gcc.gnu.org>; Fri, 02 Sep 2022 00:53:32 -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=qhBv5NS8P5nm38lsFLGvo8/8cFXpYRqXAAIh1tseZZ4=; b=DAKsqvGEXIHp9GfQ84v7VVw6FKAPCJJ9d6dc17Xs6AWK3N3lDJ2mB+ebEkncBhDZ5t f7ZtcBkXKL89iPsm+unlKewKnfNNvHpTGJqD+fYQl1hN+sk2UbesN9YwCv63N1LUdcYY fSG2lKgwakqgvZuTrW10gBdW6K3mpSugNKl3LOfdga5GZIcT0DL6gmwuhduR6OftxhaY bA5FdHG21A19IAk45EktcotY5KYzY1L7yCh0MIDkkXD3iQxU04XFQFIn24dxfuZpzBoj OJj0RwgVn1g6sAxVQCof6jbG6Gey8aMr00xRRRtatw6ZsASzmS697F4tEXJnPFjdta/P Df3A== X-Gm-Message-State: ACgBeo1t7KFDdktGy0jwk39Hi++2+EOEwqFtFe3KPM9lFmLfy96g6WrA GJacD3h1t4mNTx3IOvXze1drnoPVMYJP3A== X-Received: by 2002:a7b:c2a9:0:b0:3a6:2400:722c with SMTP id c9-20020a7bc2a9000000b003a62400722cmr1859744wmk.108.1662105211484; Fri, 02 Sep 2022 00:53:31 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id j17-20020adfea51000000b0021f0af83142sm843955wrn.91.2022.09.02.00.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 00:53:30 -0700 (PDT) Date: Fri, 2 Sep 2022 09:53:30 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Error on return of object whose full view has undefaulted discriminants Message-ID: <20220902075330.GA1121091@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline X-Spam-Status: No, score=-11.8 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= <gcc-patches@gcc.gnu.org> Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= <poulhies@adacore.com> Cc: Gary Dismukes <dismukes@adacore.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742843730999963859?= X-GMAIL-MSGID: =?utf-8?q?1742843730999963859?= |
Series |
[Ada] Error on return of object whose full view has undefaulted discriminants
|
|
Commit Message
Marc Poulhiès
Sept. 2, 2022, 7:53 a.m. UTC
The compiler wrongly reports an error about the expected type not matching the same-named found type in a return statement for a function whose result type has unknown discriminants when the full type is tagged and has an undefaulted discriminant, and the return expression is an object initialized by a function call. The processing for return statements that creates an actual subtype based on the return expression type's underlying type when that type has discriminants, and converts the expression to the actual subtype, should only be done when the underlying discriminated type is mutable (i.e., has defaulted discriminants). Otherwise the unchecked conversion to the actual subtype (of the underlying full type) can lead to a resolution problem later within Expand_Simple_Function_Return in the expansion of tag assignments (because the target type of the conversion is a full view and does not match the partial view of the function's result type). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Simple_Function_Return) Bypass creation of an actual subtype and unchecked conversion to that subtype when the underlying type of the expression has discriminants without defaults.
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -6632,7 +6632,7 @@ package body Exp_Ch6 is begin if not Exp_Is_Function_Call - and then Has_Discriminants (Ubt) + and then Has_Defaulted_Discriminants (Ubt) and then not Is_Constrained (Ubt) and then not Has_Unchecked_Union (Ubt) then