From patchwork Fri Dec 13 09:55:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1209053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515852-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="V0C4qh+F"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Z5f30Wn5z9sP6 for ; Fri, 13 Dec 2019 20:56:10 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=rZorRgHcv25+65uVaZ+KUtfjFebP/lQ/EWrCsy56RCfkRSt6rj uqnC8K2KPow7qbe4t3p95+SAua/hHTT8r4P3Y5wR+WsEYXPB5TIWcZXZQurZKxny f8FTRZ2soBXEZkV3P8YvB9Lz7/rPDdRfXDxCPDVD81CNAZzzv36MQqDqM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=FxCzoCv+d9xE7sdCsmDdKPCnILw=; b=V0C4qh+Fgz6ThxzvF2pG lOShM3vVFVqpMLHoDVqSP95Uy6rLVQ+/Ne18qK+veICkaVkI5+XVJnGDAB7XRF4K aETgRDUU6McGmkL1HwImNtq7LVkt1S3d0wCIcJ36PzMcCyzY+Aq9OAMeWNaFVrbI oNLWroeVavFeiRpuFKyTHEw= Received: (qmail 36915 invoked by alias); 13 Dec 2019 09:55:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 36796 invoked by uid 89); 13 Dec 2019 09:55:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Dec 2019 09:55:08 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 56AE6560D6; Fri, 13 Dec 2019 04:55:02 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30-CmwGyUtaE; Fri, 13 Dec 2019 04:55:02 -0500 (EST) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 09B5F560DC; Fri, 13 Dec 2019 04:55:02 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4862) id 081FB157; Fri, 13 Dec 2019 04:55:02 -0500 (EST) Date: Fri, 13 Dec 2019 04:55:02 -0500 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Clear confusion about subcomponents of atomic object Message-ID: <20191213095501.GA14055@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes The Ada RM explicitly says in the C.6 sub-chapter that, contrary to what happens for the Volatile aspect, the Atomic aspect doesn't automatically propagate down to subcomponents of atomic objects. That is not what is implemented in the compiler, in particular in the Is_Atomic_Object predicate of Sem_Util, so the change fixes this gap. It also contains a minor tweak to the Is_Atomic_Or_VFA_Object predicate. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-13 Eric Botcazou gcc/ada/ * sem_util.ads (Is_Atomic_Object): Mention relevant RM clauses. * sem_util.adb (Is_Atomic_Object): For an indexed component, only look at the Has_Atomic_Components aspect of the prefix and do not recurse on it; for a selected component, do not look at the prefix. (Is_Atomic_Or_VFA_Object): Minor tweak. --- gcc/ada/sem_util.adb +++ gcc/ada/sem_util.adb @@ -13724,54 +13724,33 @@ package body Sem_Util is ---------------------- function Is_Atomic_Object (N : Node_Id) return Boolean is - function Is_Atomic_Entity (Id : Entity_Id) return Boolean; - pragma Inline (Is_Atomic_Entity); - -- Determine whether arbitrary entity Id is either atomic or has atomic + function Prefix_Has_Atomic_Components (Pref : Node_Id) return Boolean; + -- Determine whether prefix Pref of an indexed component has atomic -- components. - function Is_Atomic_Prefix (Pref : Node_Id) return Boolean; - -- Determine whether prefix Pref of an indexed or selected component is - -- an atomic object. - - ---------------------- - -- Is_Atomic_Entity -- - ---------------------- - - function Is_Atomic_Entity (Id : Entity_Id) return Boolean is - begin - return Is_Atomic (Id) or else Has_Atomic_Components (Id); - end Is_Atomic_Entity; - - ---------------------- - -- Is_Atomic_Prefix -- - ---------------------- + --------------------------------- + -- Prefix_Has_Atomic_Components -- + --------------------------------- - function Is_Atomic_Prefix (Pref : Node_Id) return Boolean is + function Prefix_Has_Atomic_Components (Pref : Node_Id) return Boolean is Typ : constant Entity_Id := Etype (Pref); begin if Is_Access_Type (Typ) then return Has_Atomic_Components (Designated_Type (Typ)); - elsif Is_Atomic_Entity (Typ) then + elsif Has_Atomic_Components (Typ) then return True; elsif Is_Entity_Name (Pref) - and then Is_Atomic_Entity (Entity (Pref)) + and then Has_Atomic_Components (Entity (Pref)) then return True; - elsif Nkind (Pref) = N_Indexed_Component then - return Is_Atomic_Prefix (Prefix (Pref)); - - elsif Nkind (Pref) = N_Selected_Component then - return - Is_Atomic_Prefix (Prefix (Pref)) - or else Is_Atomic (Entity (Selector_Name (Pref))); + else + return False; end if; - - return False; - end Is_Atomic_Prefix; + end Prefix_Has_Atomic_Components; -- Start of processing for Is_Atomic_Object @@ -13780,12 +13759,13 @@ package body Sem_Util is return Is_Atomic_Object_Entity (Entity (N)); elsif Nkind (N) = N_Indexed_Component then - return Is_Atomic (Etype (N)) or else Is_Atomic_Prefix (Prefix (N)); + return + Is_Atomic (Etype (N)) + or else Prefix_Has_Atomic_Components (Prefix (N)); elsif Nkind (N) = N_Selected_Component then return Is_Atomic (Etype (N)) - or else Is_Atomic_Prefix (Prefix (N)) or else Is_Atomic (Entity (Selector_Name (N))); end if; @@ -13810,8 +13790,8 @@ package body Sem_Util is function Is_Atomic_Or_VFA_Object (N : Node_Id) return Boolean is begin return Is_Atomic_Object (N) - or else (Is_Object_Reference (N) - and then Is_Entity_Name (N) + or else (Is_Entity_Name (N) + and then Is_Object (Entity (N)) and then (Is_Volatile_Full_Access (Entity (N)) or else Is_Volatile_Full_Access (Etype (Entity (N))))); --- gcc/ada/sem_util.ads +++ gcc/ada/sem_util.ads @@ -1531,7 +1531,7 @@ package Sem_Util is function Is_Atomic_Object (N : Node_Id) return Boolean; -- Determine whether arbitrary node N denotes a reference to an atomic - -- object as per Ada RM C.6(12). + -- object as per Ada RM C.6(7) and the crucial remark in C.6(8). -- WARNING: There is a matching C declaration of this subprogram in fe.h