From patchwork Mon Jul 30 15:12:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 174028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 907CC2C0086 for ; Tue, 31 Jul 2012 01:12:46 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344265967; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=tuBrZKhYE7/5AD7q/iZ8 A6LMv5w=; b=YOohcdtJrw/OEWY+tlyyRIt3uPsltVexsod98FBUQrdplQ87917D hJn5f5C1TC54Mni8QpHq5vkAtNURov565EAtOFLajPX0b0odPEvN7mzi5TB2sNWV XKlTC83yauN+qqb2umI0hj3hNzukCk0iqLk0jxn2FKBDELHVl4Gynbs= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MZmH5QNvFLbmTwUMTE/t2W6YfYDaL8ULmUSlhYV6LGImp5XvSUVjJbDHniJUEB anj+Z0YF9S0p7F2IcbVZ1/SLOKGpzuW5NFob3WDXgFDDmWEaH4+doDUxqRnw54jt QSa7Vw6WIkZio8XD9JuEMDrYbVzQpCnUVu4W+5wVtRZ5A=; Received: (qmail 12088 invoked by alias); 30 Jul 2012 15:12:43 -0000 Received: (qmail 12078 invoked by uid 22791); 30 Jul 2012 15:12:42 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Jul 2012 15:12:29 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 498DF1C749E; Mon, 30 Jul 2012 11:12:28 -0400 (EDT) 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 1u5bIgmyI3Kr; Mon, 30 Jul 2012 11:12:28 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 1029E1C7497; Mon, 30 Jul 2012 11:12:28 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 0E7AD92BF6; Mon, 30 Jul 2012 11:12:28 -0400 (EDT) Date: Mon, 30 Jul 2012 11:12:28 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Pucci Subject: [Ada] New restriction for lock-free implementation Message-ID: <20120730151227.GA14362@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This patch implements a new lock-free restriction. Thus, implicit dereferences of access values prevent, as well as explicit dereference, the lock-free implementation of protected objects. The test below illustrates the new lock-free restriction: ------------ -- Source -- ------------ generic type Elmt_Type is private; type Elmt_Access is access Elmt_Type; package Test is type Node_Type; type Node_Access is access all Node_Type; type Node_Type is limited record Elmt : Elmt_Access; Prev : Node_Access; end record; protected List with Lock_Free is procedure Swap (L, R : Node_Access); private L : Node_Access := null; end List; end Test; package body Test is protected body List is ---------- -- Swap -- ---------- procedure Swap (L, R : Node_Access) is LP : constant Node_Access := L.Prev; RP : constant Node_Access := R.Prev; begin L.Prev := RP; R.Prev := LP; end Swap; end List; end Test; ----------------- -- Compilation -- ----------------- $ gnatmake -q -gnat12 test.adb test.adb:7:07: illegal body when Lock_Free given test.adb:8:40: dereference of access value not allowed test.adb:9:40: dereference of access value not allowed test.adb:12:11: dereference of access value not allowed test.adb:13:11: dereference of access value not allowed Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-30 Vincent Pucci * sem_ch9.adb (Allows_Lock_Free_Implementation): Restrict implicit dereferences of access values. Index: sem_ch9.adb =================================================================== --- sem_ch9.adb (revision 189974) +++ sem_ch9.adb (working copy) @@ -411,12 +411,15 @@ return Abandon; - -- Explicit dereferences restricted (i.e. dereferences of - -- access values). + -- Dereferences of access values restricted - elsif Kind = N_Explicit_Dereference then + elsif Kind = N_Explicit_Dereference + or else (Kind = N_Selected_Component + and then Is_Access_Type (Etype (Prefix (N)))) + then if Lock_Free_Given then - Error_Msg_N ("explicit dereference not allowed", N); + Error_Msg_N ("dereference of access value " & + "not allowed", N); return Skip; end if;