From patchwork Mon May 29 08:29:19 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: 70231 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 AA345395ACEE for ; Mon, 29 May 2023 08:37:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA345395ACEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349437; bh=yyEBZumoF2dUzYZTZ9rx/RWJaCBd3AGSmqijvNE/Szs=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=euSg5uCvFIE4E3Mgo38X1ZqACEMViiYmvpo1eQo2AqMw8r3yiin5THiKzqdz2W7Lx FjcNEXH7gWtlRfVv6/f6gRVwL8Dk+mSbCwMILKx1AzEdv7axEFxvWSXdwubApEPUJ8 o9qqxXJYz9DY3bqzXBl32khmgDzOJkDeAJS8uZfA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 717FF3855583 for ; Mon, 29 May 2023 08:29:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 717FF3855583 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-30ad8f33f1aso1714684f8f.0 for ; Mon, 29 May 2023 01:29:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685348961; x=1687940961; 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=yyEBZumoF2dUzYZTZ9rx/RWJaCBd3AGSmqijvNE/Szs=; b=Xbwo2CEaQ0CK2+6A2tEzsiL6chUlk65RDSj+t0/QRlczUuVW2dagG33+cJ/504KIcJ V2BxSBS+MRYEiwpr7EYAAEvJ6u/TrIuzDbfukh79SG5nDXk8/lH9+YCT9uRKXiTW4OJI vWu3O/Np0MRPVPyictGvLyrSF57hI0P6po2fU4OfxrGFurA/L31jQTn3TJQZodl34Mti 3znKMJdR2+27T9jeqm863XX0EzSjX2AkDqv6GuLgzgWcFJIuSaLjV87UVePjxOPBO5Od t8hZD4SOF1CybnugR3X9XcvCG/U7Shx8gyrUa6aD6GxU0O9y4R/T6NiEeaIFrW9H5fKu 9ITg== X-Gm-Message-State: AC+VfDyMvVVo7pWs1YCeD5fgurXsb6gga2UYBE14BNgaVTQzD7vDE37v rV/9BqNUgdDhH6XFzu/5sDd1LdObZU2o+CcQ5mdw0A== X-Google-Smtp-Source: ACHHUZ6UPpmvd5GQ08jPyG7S5JnmkJ1LdLymB1RZeXmIo8MhtRnLwXg0rdG5PTHMAmJEN6dr8VSErQ== X-Received: by 2002:a05:6000:196b:b0:30a:b0e7:34b with SMTP id da11-20020a056000196b00b0030ab0e7034bmr7971790wrb.66.1685348961267; Mon, 29 May 2023 01:29:21 -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 o10-20020a5d62ca000000b0030ae16132besm7296406wrv.12.2023.05.29.01.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:29:20 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Allow attributes like First and Last to be read in Exceptional_Cases Date: Mon, 29 May 2023 10:29:19 +0200 Message-Id: <20230529082919.2410012-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.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.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: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Piotr Trojanek Attributes that do not read data from the object can be safely used in consequences of Exceptional_Cases regardless of the parameter passing mode. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Relax rules for Exceptional_Cases. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_res.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index a31077a5f33..6d4bef8d38e 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -8117,11 +8117,19 @@ package body Sem_Res is -- Parameters of modes OUT or IN OUT of the subprogram shall not -- occur in the consequences of an exceptional contract unless -- they are either passed by reference or occur in the prefix - -- of a reference to the 'Old attribute. + -- of a reference to the 'Old attribute. For convenience, we also + -- allow them as prefixes of attributes that do not actually read + -- data from the object. if Ekind (E) in E_Out_Parameter | E_In_Out_Parameter and then Within_Exceptional_Cases_Consequence (N) and then not In_Attribute_Old (N) + and then not (Nkind (Parent (N)) = N_Attribute_Reference + and then + Attribute_Name (Parent (N)) in Name_Constrained + | Name_First + | Name_Last + | Name_Length) and then not Is_By_Reference_Type (Etype (E)) and then not Is_Aliased (E) then