From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21146 invoked by alias); 18 Mar 2005 04:23:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21061 invoked by uid 48); 18 Mar 2005 04:23:08 -0000 Date: Fri, 18 Mar 2005 04:23:00 -0000 Message-ID: <20050318042308.21060.qmail@sourceware.org> From: "dannysmith at users dot sourceforge dot net" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050317091946.20515.sbellon@sbellon.de> References: <20050317091946.20515.sbellon@sbellon.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug ada/20515] "stdcall" imports are not handled correctly X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg02183.txt.bz2 List-Id: ------- Additional Comments From dannysmith at users dot sourceforge dot net 2005-03-18 04:23 ------- The IS_TARGET_PE_COFF hack works on 3.4.x bit won't on trunk. Here is a cleaner patch against trunk that replaces the preprocessor tests with runtime tests. I have tested with nativr mingw bootstrap but not with cross-compile build. * decl. c (gnat_to_gnu_entity): Remove unnecessary _WIN32 preprocessor guard. (create_concat_name): Replace _WIN32 preprocessor guard with runtime chcek on TARGET_DLLIMPORT_DECL_ATTRIBUTES. Index: ada/decl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/ada/decl.c,v retrieving revision 1.65 diff -c -3 -p -r1.65 decl.c *** ada/decl.c 10 Feb 2005 13:53:20 -0000 1.65 --- ada/decl.c 18 Mar 2005 04:15:54 -0000 *************** gnat_to_gnu_entity (Entity_Id gnat_entit *** 3642,3648 **** if (list_length (gnu_return_list) == 1) gnu_return_type = TREE_TYPE (TREE_PURPOSE (gnu_return_list)); - #ifdef _WIN32 if (Convention (gnat_entity) == Convention_Stdcall) { struct attrib *attr --- 3642,3647 ---- *************** gnat_to_gnu_entity (Entity_Id gnat_entit *** 3655,3661 **** attr->error_point = gnat_entity; attr_list = attr; } - #endif /* Both lists ware built in reverse. */ gnu_param_list = nreverse (gnu_param_list); --- 3654,3659 ---- *************** create_concat_name (Entity_Id gnat_entit *** 6576,6602 **** Get_External_Name_With_Suffix (gnat_entity, fp); - #ifdef _WIN32 /* A variable using the Stdcall convention (meaning we are running on a Windows box) live in a DLL. Here we adjust its name to use the jump-table, the _imp__NAME contains the address for the NAME variable. */ ! { ! Entity_Kind kind = Ekind (gnat_entity); ! const char *prefix = "_imp__"; ! int plen = strlen (prefix); ! ! if ((kind == E_Variable || kind == E_Constant) ! && Convention (gnat_entity) == Convention_Stdcall) ! { ! int k; ! for (k = 0; k <= Name_Len; k++) ! Name_Buffer [Name_Len - k + plen] = Name_Buffer [Name_Len - k]; ! strncpy (Name_Buffer, prefix, plen); ! } ! } ! #endif ! return get_identifier (Name_Buffer); } --- 6574,6596 ---- Get_External_Name_With_Suffix (gnat_entity, fp); /* A variable using the Stdcall convention (meaning we are running on a Windows box) live in a DLL. Here we adjust its name to use the jump-table, the _imp__NAME contains the address for the NAME variable. */ ! if (TARGET_DLLIMPORT_DECL_ATTRIBUTES ! && (Ekind (gnat_entity) == E_Variable ! || Ekind (gnat_entity) == E_Constant) ! && Convention (gnat_entity) == Convention_Stdcall) ! { ! const char *prefix = "_imp__"; ! int plen = strlen (prefix); ! int k; ! for (k = 0; k <= Name_Len; k++) ! Name_Buffer [Name_Len - k + plen] = Name_Buffer [Name_Len - k]; ! strncpy (Name_Buffer, prefix, plen); ! } ! return get_identifier (Name_Buffer); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20515