From patchwork Mon Sep 12 08:19:28 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: 1151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1781691wrt; Mon, 12 Sep 2022 01:32:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6MGOOWvLtq/sM+YO24C1Cq51uEH0u4GAKlfLWQ4yoIu4MQKyFBMLx6Z8kwmiLK35hGw06x X-Received: by 2002:a17:907:2da6:b0:730:8b30:e517 with SMTP id gt38-20020a1709072da600b007308b30e517mr17886545ejc.291.1662971521729; Mon, 12 Sep 2022 01:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662971521; cv=none; d=google.com; s=arc-20160816; b=CGR7MowK/PqhQV0o9gHxiAH/eg9yiuOkTVo23mELoeXsq8wQEUvzbpr39TuobPPyB1 AlyBi+fKtU2SOBOGTi3etDLdPd97+Q+wmIqTA3oHDTmSP1yvjWx71/O9KSN5G7NKcHy/ +XgKg4OJ03K82VwL/pq1i2lGBKag6RTvfWvalBFlVZOUU1ERBDIjDDDQFcd7wHV7pahs 5PEd1pbKHvmhW+6lNUJC3FjhURxLqCjp2ltg7yGWaTWgpcVirfxWMF+tOJhuv1pCGEeH VP7qG3RWZxX1a2Ca8hSEzwltaFsNAR8qYqq3bZc4mVEsCeDCLDfH470sXhnKjg3jSjn0 0KFQ== 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=gCwTuVnC9vNQ9xJF93IE7f6XcKQztcrxzpIAJ/uwp7o=; b=ahL0Cw63x1h4bQwtthzn8dOo0R1esv83sDFcXH0QoJlpY1b2QJ+/JuqF2dKemjhTFq zzYEMR0hlSXg+8Y8e75GqCHliQLAqOAHk+nnB0l4edHbY+rK0NiyFSU1nkKMyhu87JmS EaiBr3NqgZ0RUQkNXHQciaUg36UyGRAqnyWOzSsoEfVjf9l1qjxqnoORpQMoBF0KFlvV H++phpWEaIdDd6/PWhG+mM2al7U5xGgmX5KJgYuQbYJSdbrCIJ9tQlOpVBDdIueMScGh ++kbnkXD7c4O6SO1vjdN5+FJ+JfCY0AS4n/N6D2L1f+fj6ib9tWEnSu5z0bc7HauUeg1 C3Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YwisvkYv; 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 eb7-20020a0564020d0700b00447ded5eb70si7960868edb.553.2022.09.12.01.32.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:32:01 -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=YwisvkYv; 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 D04713986402 for ; Mon, 12 Sep 2022 08:25:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D04713986402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662971102; bh=gCwTuVnC9vNQ9xJF93IE7f6XcKQztcrxzpIAJ/uwp7o=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=YwisvkYvhsmC9nMHMypcslchVm0jTMFl3r5IWfsot7D/PoWQKgkLWnY5Fpzw9FkvT NQcvpuUBdbFHLGd12RswtQGdL+JJ6DUEOQlpXKq+aD1gnMzYmIZ0NVfzNSsQw38PCU Js7rKRmJDbRsCHKc9rqFxe+VBifMs+H5K4NrLuKw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 8160C38515F6 for ; Mon, 12 Sep 2022 08:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8160C38515F6 Received: by mail-wr1-x432.google.com with SMTP id c11so14028975wrp.11 for ; Mon, 12 Sep 2022 01:19:29 -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=gCwTuVnC9vNQ9xJF93IE7f6XcKQztcrxzpIAJ/uwp7o=; b=dtzLuk/8t8ZWMHhQu+Vwr6VCHNpuW71S8DaGB9pnPxG2sQFQZ8fmiKmx28BQKMxKiM hOjcj44UJp+3PZU/g2avBRwmdY4NJ4g/RoggZmLPIfcsbH7SJ4MHKud5KVyIdQF/7T/4 vNdkOqLB8VDNNsXGfuOjAN2aD1J/J2zM6IqsZIzhkPUtYGYeF4mYbzy9gNwJCtaDtm3A +TfqKXQwysvXU2FMIDsWKVvgsrkpQQpD0JiyjiLRWL86NvnhSSflPTT5pxwn6T+ggtmN M+rprkxZTlJYn4k0R3bRSqReJX/qK+/Brqf4PKts2Q9rkBZ498ewZMsZWydg+YEVMSyN Fntg== X-Gm-Message-State: ACgBeo3/ImIU/DOLO+ylygwLeQcuwy+vP1uFHufK2sKCMZHsi534j4tx K+T6k873co/AciOiiy5gpYcWiWuXlJO4oQ== X-Received: by 2002:a05:6000:2cc:b0:22a:3c84:39a1 with SMTP id o12-20020a05600002cc00b0022a3c8439a1mr8278918wry.594.1662970769200; Mon, 12 Sep 2022 01:19:29 -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 l31-20020a05600c1d1f00b003a601a1c2f7sm9558157wms.19.2022.09.12.01.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:19:28 -0700 (PDT) Date: Mon, 12 Sep 2022 10:19:28 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix validity checking on renamed Old attribute prefix Message-ID: <20220912081928.GA1512951@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.9 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: Piotr Trojanek 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?1743752026573966793?= X-GMAIL-MSGID: =?utf-8?q?1743752026573966793?= Prefix of attribute Old is captured either as an object renaming or as an object declaration. This is now taken into account when applying validity checks. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]): Adapt to object declaration being rewritten into object renaming. diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -5088,7 +5088,17 @@ package body Exp_Attr is -- to reflect the new placement of the prefix. if Validity_Checks_On and then Validity_Check_Operands then - Ensure_Valid (Expression (Decl)); + + -- Object declaration that captures the attribute prefix might + -- be rewritten into object renaming declaration. + + if Nkind (Decl) = N_Object_Declaration then + Ensure_Valid (Expression (Decl)); + else + pragma Assert (Nkind (Decl) = N_Object_Renaming_Declaration + and then Is_Rewrite_Substitution (Decl)); + Ensure_Valid (Name (Decl)); + end if; end if; Rewrite (N, New_Occurrence_Of (Temp, Loc));