From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 3F5BD3856DDE for ; Tue, 18 Jul 2023 13:13:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F5BD3856DDE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbf1b82dc7so52697945e9.2 for ; Tue, 18 Jul 2023 06:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1689686003; x=1690290803; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qlWMgyPRDx3G6O9x6/BbXsK4z3CWjEgHF2APZ0LYL10=; b=HYEmiG6lL39rtUlHVJZC2cBRcUOm9VR0l5gJyfOrUUC5IhBX03N8hba4lxfuLlvOvP B6pRoGN0QeWW31p+aIwHLjhMoCYGQuZua6eRlukj8v9HYA+wNLXyrREmiCSlCvQQQLU+ GDOKOsju3KtaXXwNpPMLZrPnBYrkSlPNDMCumU8q5vIIPe/+SiZYzIB/2YnkaLnTeTDd F2CpShYnQLfYWi+iMKprTt1pcmkGEp4wTsvWKMZ6Vnw00V3vAVI8HIFK4k9DsAJ83bhk N68hmw4QS7cg1nlbqE3A9ZA2i991L7xK12tKx8GuTy7tS66Xb9wWIlOT6KmAKGTH9j15 LnmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689686003; x=1690290803; 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=qlWMgyPRDx3G6O9x6/BbXsK4z3CWjEgHF2APZ0LYL10=; b=dYV4CLWdCVKG05ysyLsshxlX/8o773oJZ9ZB0DJU7XF8rPDwk34vd9Yc56tFYzm3nb p99TWTBsr+9TqslrnVR3l2VP6MqPqs1jdtkmp+3n0gJWLuKNyy2fCDL4cY73gtpIVbA9 jgZa7L33ati9esuXjaV+wAeZu7u3FBWalFcpfXY66Gm8D+7GxHDJPKp7UcXFYjoiH0hn ZvDXBFNtShVr8BOFbmIBBMKsCM8Xjdxg05RlAfy5P+6FO07IQoUomTQOR1hZw8bPlYxM 4J8u9UB+ZOBLbVDzOTnTGIzA76AD4HDxGw1jMdHQqGvJwSt/I9WiNs1y64vkSdSmO2rV yiQg== X-Gm-Message-State: ABy/qLZCu3oS7v9//4kNSzGfUbGpnd1ABMWQtrjnpzELYNsbF8wkV5KQ 94kKfkqa+OkDHQ6r6TVg+3dMYVHp+7fbBTeOijFFMw== X-Google-Smtp-Source: APBJJlFv0d+KJRmZnXCSBRUkZue0+F/mV38HojhTUNCnF7Z4yAJfRqu+vJ8npllkkssdcyILCo/rrQ== X-Received: by 2002:a05:600c:20c1:b0:3fa:9767:c816 with SMTP id y1-20020a05600c20c100b003fa9767c816mr1700951wmm.39.1689686003019; Tue, 18 Jul 2023 06:13:23 -0700 (PDT) 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 k25-20020a7bc419000000b003fbc30825fbsm2089127wmi.39.2023.07.18.06.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:13:22 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix Valid_Scalars attribute applied to types from limited with Date: Tue, 18 Jul 2023 15:13:11 +0200 Message-Id: <20230718131311.80670-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: From: Eric Botcazou The attribute is wrongly computed as always True because, unlike for e.g. private types, Validated_View does not look through the limited view. gcc/ada/ * sem_util.ads (Validated_View): Document enhanced behavior. * sem_util.adb (Validated_View): Return the nonlimited view, if any, of types coming from a limited with. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 7 +++++++ gcc/ada/sem_util.ads | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 821aacf1ccb..222fd72a061 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -29231,6 +29231,13 @@ package body Sem_Util is return Typ; end if; + elsif From_Limited_With (Typ) then + if Has_Non_Limited_View (Typ) then + return Validated_View (Non_Limited_View (Typ)); + else + return Typ; + end if; + else return Typ; end if; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 3751fb73702..7fc77de2b8a 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -3331,8 +3331,8 @@ package Sem_Util is function Validated_View (Typ : Entity_Id) return Entity_Id; -- Obtain the "validated view" of arbitrary type Typ which is suitable for -- verification by attribute 'Valid_Scalars. This view is the type itself - -- or its full view while stripping away concurrency, derivations, and - -- privacy. + -- or its full view or nonlimited view, while stripping away concurrency, + -- derivations, and privacy. function Visible_Ancestors (Typ : Entity_Id) return Elist_Id; -- [Ada 2012:AI-0125-1]: Collect all the visible parents and progenitors -- 2.40.0