From patchwork Tue May 15 10:22:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 159284 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 7C827B6FAC for ; Tue, 15 May 2012 20:22:53 +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=1337682174; 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=gJFAxLj2ZetUyGV8DUtS qiZ+1cg=; b=qKKSMygOi7fWx5zvaUAf+ZzaTY/AoZ90rXIyAs/zj7sMJyonjvJP +4diJi61a+iTfDvqoFCTOEgddNs5czHpw+WeoitGzPhet7bFtEKIk6QhpwPgjpO1 Q0TXMAkSqWeTfKh37ZTl5WVZVFHeJNvCI2P1wjNMQ3/2ZiXKC72aCIA= 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=Np2+ihsI86E8ZF5twBi7QP9CgBa9uuPdFdy/dmlKcjn16gk42GPiDU61t2NmVS 3aPnkZirVnrE0cfeLO/HByanfSPo1ImfQlEx+w14Ml8ZNsuNl1bUhuecLvo2lyMS mgNeCHS4B7GH+jeA9sx46sReF9O8tuDjhoWCdWs3/eNHU=; Received: (qmail 8298 invoked by alias); 15 May 2012 10:22:38 -0000 Received: (qmail 8284 invoked by uid 22791); 15 May 2012 10:22:36 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL 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; Tue, 15 May 2012 10:22:23 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BAC941C6B7F; Tue, 15 May 2012 06:22:22 -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 rpSWT2tOgWwn; Tue, 15 May 2012 06:22:22 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8EAEE1C6A9A; Tue, 15 May 2012 06:22:22 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 872BF92BF6; Tue, 15 May 2012 06:22:22 -0400 (EDT) Date: Tue, 15 May 2012 06:22:22 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Missing DSA remote access to subprogram rules enforcement Message-ID: <20120515102222.GA13473@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 change adds missing code to enforce language restrictions for remote access to subprogram types in the case of 'Unchecked_Access and 'Unrestricted_ Access. The following compilation must be rejected with the given error message: $ gcc -c server_main.adb server_main.adb:11:35: prefix must statically denote a remote subprogram package Queue is pragma Remote_Call_Interface; type Result_Callback is access procedure (Job : in Integer); procedure Append_Job (Job : in Integer; Callback : in Result_Callback); procedure Set_Result (Job : in Integer); end Queue; with Ada.Text_IO; with Queue; procedure Server_Main is use Ada; procedure Set_Result (Id : in Integer) is begin null; end Set_Result; begin Text_IO.Put_Line ("Start server..."); Queue.Append_Job (1, Set_Result'Unrestricted_Access); end Server_Main; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Thomas Quinot * sem_res.adb (Resolve): Enforce E.2.2(11/2) and E.2.2(12) for 'Unrestricted_Access and 'Unchecked_Access (not just 'Access): even in those cases, a remote access type may only designate a remote subprogram. Index: sem_res.adb =================================================================== --- sem_res.adb (revision 187501) +++ sem_res.adb (working copy) @@ -1967,7 +1967,10 @@ -- Prefix (N) must statically denote a remote subprogram -- declared in a package specification. - if Attr = Attribute_Access then + if Attr = Attribute_Access or else + Attr = Attribute_Unchecked_Access or else + Attr = Attribute_Unrestricted_Access + then Decl := Unit_Declaration_Node (Entity (Pref)); if Nkind (Decl) = N_Subprogram_Body then @@ -1990,26 +1993,22 @@ ("prefix must statically denote a remote subprogram ", N); end if; - end if; - -- If we are generating code for a distributed program. - -- perform semantic checks against the corresponding - -- remote entities. + -- If we are generating code in distributed mode, perform + -- semantic checks against corresponding remote entities. - if (Attr = Attribute_Access or else - Attr = Attribute_Unchecked_Access or else - Attr = Attribute_Unrestricted_Access) - and then Full_Expander_Active - and then Get_PCS_Name /= Name_No_DSA - then - Check_Subtype_Conformant - (New_Id => Entity (Prefix (N)), - Old_Id => Designated_Type - (Corresponding_Remote_Type (Typ)), - Err_Loc => N); + if Full_Expander_Active + and then Get_PCS_Name /= Name_No_DSA + then + Check_Subtype_Conformant + (New_Id => Entity (Prefix (N)), + Old_Id => Designated_Type + (Corresponding_Remote_Type (Typ)), + Err_Loc => N); - if Is_Remote then - Process_Remote_AST_Attribute (N, Typ); + if Is_Remote then + Process_Remote_AST_Attribute (N, Typ); + end if; end if; end if; end if;