From patchwork Mon Jul 8 08:10:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 257499 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BE7372C009D for ; Mon, 8 Jul 2013 18:10:39 +1000 (EST) 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=XPBCvSwuungahX9MZW3oNyNOWvXNXte5yCcbQ/0CNDoLC8fVRY URLuIP0FxuB7Rt/PkWTelZ+v62b2obxRIuwmLW0qM1slNR2+uhZ9plfFV/1KJMQL FXIWkvqZcBvjGJmw+RErrMRsDp1l3pLUER6ZA82tQHTv69fub6Q9ATvpk= 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=VBx0ZWPlCQJ78kiF/spmLAYHekw=; b=oIBRuTMabpuYhOAkH4ba fks9SCDa4nYwXRXp4ys4KYUOfNTpzShMYhgAGYjQpRpxGPVEyhWVuWo2hbPObDN6 CUely0EYfz5tyLD3ScTsTywViPjcv5DbE1uR/S2Gpi3Aul1H59s6z2dnmp1ARRx3 XAfLzKc4ShZd/jmJ+Atr17U= Received: (qmail 10683 invoked by alias); 8 Jul 2013 08:10:32 -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 10670 invoked by uid 89); 8 Jul 2013 08:10:32 -0000 X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 08 Jul 2013 08:10:31 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 104AC1C68C8; Mon, 8 Jul 2013 04:10:30 -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 t81buJ2sdamd; Mon, 8 Jul 2013 04:10:30 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id E169F1C68C6; Mon, 8 Jul 2013 04:10:29 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id DF1683FB31; Mon, 8 Jul 2013 04:10:29 -0400 (EDT) Date: Mon, 8 Jul 2013 04:10:29 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Type conformance for access_to_subprogram types Message-ID: <20130708081029.GA7019@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Found: No Two anonymous_access_to_subprograsm types are type conformant if the designated type of one is protected and the other is not. Convention of the designated types only matters when checking subtype conformance. Previous to this patch, the compiler failed to recognize that the following declarations are illegal homonyms: --- package P is function F return access procedure (I : Integer); function F return access protected procedure (I : Integer); end P; --- Compiling the above with -gnatc must yield: p.ads:4:13: "F" conflicts with declaration at line 3 Tested on x86_64-pc-linux-gnu, committed on trunk 2013-07-08 Ed Schonberg * sem_ch6.adb (Conforming_Types): Anonymous_access_to_subprograsm types are type conformant if the designated type of one is protected and the other is not. Convention only matters when checking subtype conformance. Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 200688) +++ sem_ch6.adb (working copy) @@ -2789,11 +2789,11 @@ and then (Nkind (Original_Node (Spec_Decl)) = N_Subprogram_Renaming_Declaration - or else (Present (Corresponding_Body (Spec_Decl)) - and then - Nkind (Unit_Declaration_Node - (Corresponding_Body (Spec_Decl))) = - N_Subprogram_Renaming_Declaration)) + or else (Present (Corresponding_Body (Spec_Decl)) + and then + Nkind (Unit_Declaration_Node + (Corresponding_Body (Spec_Decl))) = + N_Subprogram_Renaming_Declaration)) then Conformant := True; @@ -7663,13 +7663,16 @@ end if; -- Ada 2005 (AI-254): Anonymous access-to-subprogram types must be - -- treated recursively because they carry a signature. + -- treated recursively because they carry a signature. As far as + -- conformance is concerned, convention plays no role, and either + -- or both could be access to protected subprograms. Are_Anonymous_Access_To_Subprogram_Types := - Ekind (Type_1) = Ekind (Type_2) + Ekind_In (Type_1, E_Anonymous_Access_Subprogram_Type, + E_Anonymous_Access_Protected_Subprogram_Type) and then - Ekind_In (Type_1, E_Anonymous_Access_Subprogram_Type, - E_Anonymous_Access_Protected_Subprogram_Type); + Ekind_In (Type_2, E_Anonymous_Access_Subprogram_Type, + E_Anonymous_Access_Protected_Subprogram_Type); -- Test anonymous access type case. For this case, static subtype -- matching is required for mode conformance (RM 6.3.1(15)). We check