From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-wr1-x432.google.com with SMTP id c11so14028975wrp.11 for ; Mon, 12 Sep 2022 01:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=gCwTuVnC9vNQ9xJF93IE7f6XcKQztcrxzpIAJ/uwp7o=; b=RYi6y/CrQZygHUBgxuu80daIvtkwsuil23e+/VzMVtRtxHJKjK1XpQKpyEX2KToC7a qUNk1yLOWkBubAVArTpI11tT1m4XNIjsOv1cf6MiSrwN9zVTnipfDvT4jzhDFCWdToSO luZRapoxUPgH1blj818Ezoz4uYbEmDCX3YMOUb5vXPSgfIzCo1aFPJWnbGOgjrN5ifWT qhRG920pOjS0wc6CRP2gP+B732EQp5oVl9H3zl1QiSJeMJ4V1mcQfjYRhUrqI3EkeI+6 Wj6T9eok8tGL2lFVLgmA+iFyaUsT9zZxeVOafZpMovL0A7WZq0/pSVT40HHN8M/AvgQO b4tA== 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-Google-Smtp-Source: AA6agR7PkUNeOROrvsVO/UHeVUqOQpDUmx6xjL3dclNMJykxoz1pgyGiw2V4HmXq2TpZsWRLtASA7A== 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 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Fix validity checking on renamed Old attribute prefix Message-ID: <20220912081928.GA1512951@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="WIyZ46R2i8wDzkSu" 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 List-Id: --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --WIyZ46R2i8wDzkSu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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)); --WIyZ46R2i8wDzkSu--