This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/20515] "stdcall" imports are not handled correctly
- From: "dannysmith at users dot sourceforge dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Mar 2005 04:23:08 -0000
- Subject: [Bug ada/20515] "stdcall" imports are not handled correctly
- References: <20050317091946.20515.sbellon@sbellon.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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