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: 81011 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 A38203861813 for ; Thu, 30 Nov 2023 10:20:06 +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-Google-Smtp-Source: AGHT+IGRfdBonQ0Yy1om8El+yzD8eNY+pFALrSWdqUVDI5nIQFm7xaw04xPlZY5jpqRB96R4jcnvvw== 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+patchwork=sourceware.org@gcc.gnu.org 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;