From patchwork Thu Nov 30 10:19:03 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: 171805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp281818vqy; Thu, 30 Nov 2023 02:20:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHc2CaFhcR0MzpTufkFKyShYHd9FpN4w5chiBTg8v2N2/WTygGEtkBHmtoq613CB+h6ZuYD X-Received: by 2002:a67:f78e:0:b0:464:6050:9f0d with SMTP id j14-20020a67f78e000000b0046460509f0dmr63545vso.29.1701339629604; Thu, 30 Nov 2023 02:20:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701339629; cv=pass; d=google.com; s=arc-20160816; b=FWS7ua075IWQFthdYdL1Jjv5n3JnrAVGvcQ3u1eOxy7mWiKbl1ojlRhLJ8u2A9FD5c xT7BA0ENdMCTQtjs1H0DWudc9+Oon5LF1hapZWUA7aRa79cJ0Iu0m660sSzO7tsvx8YJ xbhs7A+xzF1Ame0XOVcqFS0mEh8G6eOZy8ALvngtZdfdoQu2X5Ps/fsgFMUQGPo/plwo zc9WMY/Vp8HUf4PCx/4xeG8y8AxZFuoNpMZqVH/QRqhWlfH7y9/r7U8MS6TXL+/NFdkA lQm6LxbVSo7lmbUNTbvbtDNxcbpQFDTNfytIKwxSg8g2jjy99YK4rILNz6VCIaXCtpRi iGtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=jNVwqxg/VnTO0Z4xSHGeJ0CExPA1xVqZa4bouU36OTg=; fh=VfpjIVwbQyKCLGOH4P8eKpbC0rx5s9zOz2f2H065zJg=; b=m7ynYogrkGU44Qrqn71Y52mD8vefYmqKhfvG5GWHuAsd8CHx9w/SFkmLQR49UuR77u /UhG8eW7JcxVnIThtXWMMEysUaIgTTQQ4SOpLfuT4DvySknUksnuTRg9wEfMUqqALXtC NjK228bJJB88L56ZMitV/GGR+X5yBMCgKU6BvyV3d8q1+ssvAjnhgFUf1VYh6drVzH+G ZmODKTk81m5Di/vcW591NDvrWHKiJpF9P8F3RQBw1e5NEDAzQAojxVmsYlvn3qmulQqM 0hvsBuqN7zQ0shH7lATCfvbeDUFievLoansoGIfnGk6k3cFvXGeTz6eBqmMUeTuU/2bY cHRQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b="OUwi+c/t"; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m22-20020a05620a291600b0077da7ff318esi747045qkp.685.2023.11.30.02.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:20:29 -0800 (PST) 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=@adacore.com header.s=google header.b="OUwi+c/t"; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18376386188C for ; Thu, 30 Nov 2023 10:20:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 5468A3858023 for ; Thu, 30 Nov 2023 10:19:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5468A3858023 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 5468A3858023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701339548; cv=none; b=EC15lCTtdcP+sRjKCZKJS4P2818+BqjG4LNnd3jPfaqzOMEcIy9MT7GITL0/xK4Xk5e2y3u4Cq7/YDkWQWz2F67V0xMNgvhSHUNO3J+AI/8V/YZlmVT6Ns+h+9wiPShgPwpuyfH4SEJEZgzQmOhiDZO43ePtlFJkgyafcUZyqZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701339548; c=relaxed/simple; bh=AsE0uJURGN5n8/Rah3hSeGQTptzq8FkTlpkuNRqMJx4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=OeBL10pDd9qx9G+KnPL5eQMZAaEELu37E8mqQX0+3/nldFUDXURPjTF780dpEYidi7Q0WT4ZgytxohBUHclEfgqPScELqeNQOajfrD1EbW5WMwg/2OXgJV7g7Igs9IEA4PnsJJLDEDdfAofJMdG7qmjIc2cwaL5LAU9YX0tfJcE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40b4f6006d5so6334605e9.1 for ; Thu, 30 Nov 2023 02:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701339545; x=1701944345; 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=jNVwqxg/VnTO0Z4xSHGeJ0CExPA1xVqZa4bouU36OTg=; b=OUwi+c/tzz4dzvOYSnxX1uSUuvIip6/ysGbfk0MBA7RX8iFOTDPDDcxatU8piwuVF9 nXo6Y3gqlTkmZGh2Qd+3T454eCcFyUdo0DqRoe5U0AkzEkzn8Mby63kVIMwCNEVqLcnB s8gopR4S2suiiaMxn3rtGifpA12y9Fd9WYLU/4Ts7VogZUfxDGO7r21rcjdP603IC8+y tEsms5smN++n81smQJ88Z4zfIDTrZSSjtyb7si/xCZEOuEMQCsiBPw/fJO93avV6uVNI a0mmrG9qm5cFYkUb0Zr4PhoE6+nmUIYXoLsYvNW/6clx1hCZY5w/a9F3B9iNp+LCzNB3 3uPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339545; x=1701944345; 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=jNVwqxg/VnTO0Z4xSHGeJ0CExPA1xVqZa4bouU36OTg=; b=Vo+o1BMgzTm6xNYD5qOlCjQ+N+2IxfUSrlGyNSoOWUAifmdUyBem/nLs5OkxxnwUxL EIVt2+3767A06hlArGABTY0/MXy5NOiYj48kmgMdhhvDoI7qx5NYkW5wsXuZ2Z5XKssk N5/QQRKofbrjAzx1xUMomjw14DsiRE954OtezQpfYsJiooDT+WKliK8f1nj/KWzzNE4A 9md8a54V0DBWARaHatjxaZwE9awCvJ1n17H2+8UqZ+oMMuste4NFq8WDf5Ss5cSpCBPB 3+kb3AdCB9qB6tdktSeSCfJ79k0xvqOcs6u8LNpZLZVuNeKyJySZ7Ora1yYw2w26/+oX XK4A== X-Gm-Message-State: AOJu0YxMCXn2ufxtBgCbHaEoGlxRVrUvVmlszt0tz00MlBTwZ2UGwnQ6 nLJqNfeZE7YtfqHzxUdr6zdxhOqduywVwfSmGdApvQ== X-Received: by 2002:a05:600c:450b:b0:40b:37ec:377f with SMTP id t11-20020a05600c450b00b0040b37ec377fmr12381533wmo.25.1701339545115; Thu, 30 Nov 2023 02:19:05 -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 fa10-20020a05600c518a00b00405442edc69sm5117391wmb.14.2023.11.30.02.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:19:04 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED] ada: Too-strict conformance checking for formal discriminated type Date: Thu, 30 Nov 2023 11:19:03 +0100 Message-ID: <20231130101904.3094006-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783983903822767356 X-GMAIL-MSGID: 1783983903822767356 From: Steve Baird The discriminant subtype conformance check for an actual parameter corresponding to a generic formal discriminated type was too strict and could incorrectly reject legal instantiations. gcc/ada/ * sem_ch12.adb (Validate_Discriminated_Formal_Type): Replace Entity_Id equality test with a call to Subtypes_Match. Distinct subtypes which are statically matching should pass this test. (Check_Discriminated_Formal): Replace Entity_Id equality test with a call to Subtypes_Statically_Match (preceded by a check that the preconditions for the call are satisfied). Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 7c645c490ae..ea85e88d753 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -14001,9 +14001,10 @@ package body Sem_Ch12 is and then (Ekind (Base_Type (Etype (Actual_Discr)))) = E_Anonymous_Access_Type and then - Get_Instance_Of - (Designated_Type (Base_Type (Formal_Subt))) = - Designated_Type (Base_Type (Etype (Actual_Discr))) + Subtypes_Match + (Get_Instance_Of + (Designated_Type (Base_Type (Formal_Subt))), + Designated_Type (Base_Type (Etype (Actual_Discr)))) then null; @@ -17322,8 +17323,14 @@ package body Sem_Ch12 is and then (Ekind (Base_Type (Etype (Actual_Discr)))) = E_Anonymous_Access_Type and then - Designated_Type (Base_Type (Formal_Subt)) = - Designated_Type (Base_Type (Etype (Actual_Discr))) + Base_Type + (Designated_Type (Base_Type (Formal_Subt))) = + Base_Type + (Designated_Type (Base_Type (Etype (Actual_Discr)))) + and then + Subtypes_Statically_Match + (Designated_Type (Base_Type (Formal_Subt)), + Designated_Type (Base_Type (Etype (Actual_Discr)))) then null;