From patchwork Tue Apr 25 10:31:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 754701 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wBzzK6j80z9s80 for ; Tue, 25 Apr 2017 20:31:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BcS72z1M"; dkim-atps=neutral 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=JEQNHbpvQ3tHXr/J6HeUViewjdb9bdPggbkTC//luPa8WSwX/W lTI4rDKW+3AOt1vkmKaMkAnxLtxJ7fGb4o67qCLMOO5Z704dpW4euC6uUMzKnWL6 29iKUWH1dyx6oGn49dMQ8v8WrDjws6sJqFeHJQ/fUHYwNDHh9GWafWKwo= 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=ANCx32k9rh4zrrab/fRBsurDI3E=; b=BcS72z1MXtxIqOUocM91 QdnFBmJvdwpR6bF3O0uchdkWALHqBNIZ68kr1vs0RhYU9yzYLhHGeJJ8hN0onong zp5iskZ5gbnUnK50Y9QqrNxkZ5foqQ9LTTb5OvZDwHosGO35RYNJPz4yQu7fkESF h3L8VMm7v1qHIJi69pulUos= Received: (qmail 29435 invoked by alias); 25 Apr 2017 10:31:41 -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 29413 invoked by uid 89); 25 Apr 2017 10:31:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 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; Tue, 25 Apr 2017 10:31:39 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 794463595; Tue, 25 Apr 2017 06:31:40 -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 cUS0aqfZEP3F; Tue, 25 Apr 2017 06:31:40 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 65B253410; Tue, 25 Apr 2017 06:31:40 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 61A003F0; Tue, 25 Apr 2017 06:31:40 -0400 (EDT) Date: Tue, 25 Apr 2017 06:31:40 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Use of convention aspect Stdcall on a record component. Message-ID: <20170425103140.GA122738@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes a spurious error on a record component whose type is an anonymous access to subprogram, when the component carries the Windows convention Stdcall. The following must compile quietly: --- package P is type T is record AF : access function (i:Integer) return integer with convention => stdcall; end record; -- the convention stdcall,dll,win32 are not supported,while -- C,CPP,FORTRAN etc. are supported. -- Of course,we can write as below,but one line more. type AF_Type is access function (i:Integer) return integer with convention => stdcall; type TOK is record AF : AF_Type; end record; end p; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Ed Schonberg * sem_prag.adb (Set_Convention_From_Pragma): Cleanup code for convention Stdcall, which has a number of exceptions. Convention is legal on a component declaration whose type is an anonymous access to subprogram. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 247175) +++ sem_prag.adb (working copy) @@ -7401,24 +7401,32 @@ ("dispatching subprogram# cannot use Stdcall convention!", Arg1); - -- Subprograms are not allowed + -- Several allowed cases - elsif not Is_Subprogram_Or_Generic_Subprogram (E) + elsif Is_Subprogram_Or_Generic_Subprogram (E) -- A variable is OK - and then Ekind (E) /= E_Variable + or else Ekind (E) = E_Variable + -- A component as well. The entity does not have its + -- Ekind set until the enclosing record declaration is + -- fully analyzed. + + or else Nkind (Parent (E)) = N_Component_Declaration + -- An access to subprogram is also allowed - and then not - (Is_Access_Type (E) - and then Ekind (Designated_Type (E)) = E_Subprogram_Type) + or else (Is_Access_Type (E) + and then Ekind (Designated_Type (E)) = E_Subprogram_Type) -- Allow internal call to set convention of subprogram type - and then not (Ekind (E) = E_Subprogram_Type) + or else (Ekind (E) = E_Subprogram_Type) then + null; + + else Error_Pragma_Arg ("second argument of pragma% must be subprogram (type)", Arg2);