From patchwork Wed Dec 7 11:47:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 87031 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp270160qgi; Wed, 7 Dec 2016 03:48:44 -0800 (PST) X-Received: by 10.84.142.70 with SMTP id 64mr145146686plw.177.1481111324374; Wed, 07 Dec 2016 03:48:44 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q11si23006143pfc.143.2016.12.07.03.48.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 03:48:44 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443672-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443672-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443672-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=REh1bF9s17iY1NNB IrnFXLWVXAYNIG4yM5tnUAo/poNvli7UBQZxuHB75mFiCdJKr8XRVNMjMx9jf/81 68H5kryVPDcn63txp19nlCxrapvj1qB8ko2VyLZAEuJCZgjibbwug5cWhwX82K3e Hjahr249jL/vU2IW7nvhqMnjoL4= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=63UhHjWAxOF5THqy3FulV0 qqzj4=; b=EGWyUsx3ef+u3bhtBuAQEBeZ6uLPE7e3ept+JDTcIIbyNjD1uwCwsR qeoK0VZQLcYEpx0VSwdii00AOrOPVb1EXGb5pJvJlsbMYv1PHztTquelGMFao00J skofkUxu4BJ9+l7ekVbUXncHKktHjtWHjWXdFGO79P6XWqX+pKcwA= Received: (qmail 46640 invoked by alias); 7 Dec 2016 11:47:57 -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 46578 invoked by uid 89); 7 Dec 2016 11:47:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Translate, declc, entity_id, sk:gnat_to X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Dec 2016 11:47:43 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 189E3814E1 for ; Wed, 7 Dec 2016 12:47:40 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nYhz7Xpk9Uju for ; Wed, 7 Dec 2016 12:47:40 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id E6598812DF for ; Wed, 7 Dec 2016 12:47:39 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Translate System.Address into void* for foreign convention Date: Wed, 07 Dec 2016 12:47:39 +0100 Message-ID: <2047812.XhmEgajTuQ@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-48-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This was already the case for convention C. Tested on x86_64-suse-linux, applied on the mainline. 2016-12-07 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Translate System.Address into ptr_type_node for every foreign convention. (gnat_to_gnu_subprog_type): Likewise for result and parameter types. (gnat_to_gnu_param): Do not do it here for GCC builtins. (intrin_return_compatible_p): Likewise. -- Eric Botcazou Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 243336) +++ gcc-interface/decl.c (working copy) @@ -645,7 +645,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } /* Get the type after elaborating the renamed object. */ - if (Convention (gnat_entity) == Convention_C + if (Has_Foreign_Convention (gnat_entity) && Is_Descendant_Of_Address (gnat_type)) gnu_type = ptr_type_node; else @@ -5404,12 +5404,6 @@ gnat_to_gnu_param (Entity_Id gnat_param, gnu_param_type = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_param_type)))); - /* For GCC builtins, pass Address integer types as (void *) */ - if (Convention (gnat_subprog) == Convention_Intrinsic - && Present (Interface_Name (gnat_subprog)) - && Is_Descendant_Of_Address (gnat_param_type)) - gnu_param_type = ptr_type_node; - /* Arrays are passed as pointers to element type for foreign conventions. */ if (foreign && mech != By_Copy && TREE_CODE (gnu_param_type) == ARRAY_TYPE) { @@ -5784,7 +5778,9 @@ gnat_to_gnu_subprog_type (Entity_Id gnat else { - if (Convention (gnat_subprog) == Convention_C + /* For foreign convention subprograms, return System.Address as void * + or equivalent. Note that this comprises GCC builtins. */ + if (Has_Foreign_Convention (gnat_subprog) && Is_Descendant_Of_Address (gnat_return_type)) gnu_return_type = ptr_type_node; else @@ -5949,7 +5945,9 @@ gnat_to_gnu_subprog_type (Entity_Id gnat { Entity_Id gnat_param_type = Etype (gnat_param); - if (Convention (gnat_subprog) == Convention_C + /* For foreign convention subprograms, pass System.Address as void * + or equivalent. Note that this comprises GCC builtins. */ + if (Has_Foreign_Convention (gnat_subprog) && Is_Descendant_Of_Address (gnat_param_type)) gnu_param_type = ptr_type_node; else @@ -8910,10 +8908,6 @@ intrin_return_compatible_p (intrin_bindi && !VOID_TYPE_P (btin_return_type)) return true; - /* If return type is Address (integer type), map it to void *. */ - if (Is_Descendant_Of_Address (Etype (inb->gnat_entity))) - ada_return_type = ptr_type_node; - /* Check return types compatibility otherwise. Note that this handles void/void as well. */ if (intrin_types_incompatible_p (btin_return_type, ada_return_type))