From patchwork Mon May 15 09:41:54 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: 94020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6790724vqo; Mon, 15 May 2023 02:44:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5heZZRIyG/F1Xd8+rEapKRZ4PqLzARCNIc3uFvs2xAFtF1IIqxlKwXXmC7FnqiWPGIGA2I X-Received: by 2002:a17:907:1b24:b0:94e:5c28:1c19 with SMTP id mp36-20020a1709071b2400b0094e5c281c19mr32458835ejc.5.1684143882143; Mon, 15 May 2023 02:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684143882; cv=none; d=google.com; s=arc-20160816; b=hRyb6I9kjsPkbGjq6Jf0r9x3cE6MA6YE8IOZS5fNSMwW8UihZQgpwr0FxWA8597VKG tVhwCkMz89vGdAPqjXu+kXtVnoBqt2p82q8H8rD6SsbBJ9x94ds8CKC1AwLirtcnGpq/ zKC0MmezQ9MgqWW1Niz/DPl5qpaXO0SJYevGm4EQy3bvn7x+Z97O7D7Ro/3meNLKSD+1 q6k/kW0v48NQOt66JnYWlteQx/Phpv3VgAyDbl9mkcf5Bd5bj5VgWBn1qk3VbwTJ5aLL hadhNsA1gK3xzeJ8a8Hxz0p+VWS8vUG4wypCfoa2rjyBSEdJr25fLPz1wZ6prUnWH5vu 8JsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=+Xb2kOeLXQlvLSm0qVgcsgZ+8XNdpnTJfK4Str8sUIU=; b=ZOx4Tp+JEDPdRidXZVNWFeb0c/OuCW0T4/4r1bKSygWA19xO7yD1Pzwy6Lw5R9QK4v 9eR16N+ITru6NKmek8qYNGYOHITXkq0MPZj7+dS5V6QgT2DadRmFodKZLneYDWACXUci Ce3qINyy0XefIaKjBBGLfTWtOUPp0soq8hrjwRODB0AbkRr3Uu+LQygP9bB6K+oXt+8l 3TBZQfCJ11WwHXBes7tGwF4TJYdGJ7+NY877wC0Z2P0n2AAFyk+Nyir4GJx1lKcTUtKP P9MHBAJtn2aNDVHbfu7R0dvC7rDkhhGT1fDamDTfzsnGJofiJxSRZNuY2HOA3jZDMGBu ESlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="h3PD/siv"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id qa6-20020a170907868600b0094effaaa050si13393154ejc.50.2023.05.15.02.44.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:44:42 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="h3PD/siv"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 15C60385292A for ; Mon, 15 May 2023 09:43:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15C60385292A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684143817; bh=+Xb2kOeLXQlvLSm0qVgcsgZ+8XNdpnTJfK4Str8sUIU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=h3PD/sivzdhE0VeSyi8+kKRfBEiz6adCFGUPJ42+qIpNCuFi45nSJ2eQdb/MsTxh1 jmQTtfaFWc13i9hcn7wj1xndsky3nV3wBKqrEt4ZJiPT4n9CdImoWIHnnf6+7bwQ3F WVCjkUavLLhva2//MEgfIn5I+7oekcrgsM733KKY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 509D83857739 for ; Mon, 15 May 2023 09:42:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 509D83857739 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-306f2b42a86so8165775f8f.3 for ; Mon, 15 May 2023 02:42:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143721; x=1686735721; 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=+Xb2kOeLXQlvLSm0qVgcsgZ+8XNdpnTJfK4Str8sUIU=; b=FJfQfD88EQzfREUQN7jwfHXnRTJYpgtxip0bnIPeBUZC1IymFd+0dTXeYBup7rq6ZF yz3ujAuO2qtJ1tjeDk45NclB4tTCL8KvGF0iO1Yt5/CwbPL1RGe56a6BCN/yYXhSYkoY UuPYjmdhg2JHw5llhNfMnO+IwjKPqEykeaws26l/ziDhmW00weR/97sPE9O4bsNagwhm Mm0XKj8FE6MGkXn0FPzLbwaRVOx6MyxTvE2jxkLfAYMzgTSUHYIw7G1BuKxhC+BKgvMQ htqA5gjLxgDLFO4B4wYvKyj5CFWGa7bwvPkYzX7TAVIecvkoWMuQdfFX4noqoY9j+JKs jRpQ== X-Gm-Message-State: AC+VfDy7WfLZQbrE2Szza3z8N2oyDG3r807rWgnEhYdPS65lc0UXYTFw /MkK+YAfHgZLGu+G5QXsY+ZQGb8rqGno5+j7GWpN5A== X-Received: by 2002:a5d:5308:0:b0:306:3a47:cd78 with SMTP id e8-20020a5d5308000000b003063a47cd78mr22533007wrv.71.1684143721110; Mon, 15 May 2023 02:42:01 -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 s6-20020adff806000000b003068f5cca8csm31545326wrp.94.2023.05.15.02.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:42:00 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Reject attribute Initialize on unchecked unions Date: Mon, 15 May 2023 11:41:54 +0200 Message-Id: <20230515094154.1407371-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765952855038595328?= X-GMAIL-MSGID: =?utf-8?q?1765952855038595328?= From: Piotr Trojanek Attribute Initialized is expanded into Valid_Scalars, which can't work on unchecked unions, so Initialized on unchecked unions needs to be rejected before expansion. gcc/ada/ * sem_attr.adb (Analyze_Attribute): Reject attribute Initialized on unchecked unions; fix grammar in comment. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_attr.adb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index a9e64b7655d..77c56aa587b 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -4613,7 +4613,7 @@ package body Sem_Attr is if Comes_From_Source (N) then - -- This attribute be prefixed with references to objects or + -- This attribute can be prefixed with references to objects or -- values (such as a current instance value given within a type -- or subtype aspect). @@ -4621,6 +4621,13 @@ package body Sem_Attr is and then not Is_Current_Instance_Reference_In_Type_Aspect (P) then Error_Attr_P ("prefix of % attribute must be object"); + + -- Just like attribute 'Valid_Scalars this attribute is illegal + -- on unchecked union types. + + elsif Has_Unchecked_Union (Validated_View (P_Type)) then + Error_Attr_P + ("attribute % not allowed for Unchecked_Union type"); end if; end if;