public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dannysmith at users dot sourceforge dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/20515] "stdcall" imports are not handled correctly
Date: Fri, 18 Mar 2005 04:23:00 -0000	[thread overview]
Message-ID: <20050318042308.21060.qmail@sourceware.org> (raw)
In-Reply-To: <20050317091946.20515.sbellon@sbellon.de>


------- 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


  parent reply	other threads:[~2005-03-18  4:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-17  9:20 [Bug ada/20515] New: " sbellon at sbellon dot de
2005-03-17  9:58 ` [Bug ada/20515] " charlet at adacore dot com
2005-03-18  3:30 ` dannysmith at users dot sourceforge dot net
2005-03-18  4:23 ` dannysmith at users dot sourceforge dot net [this message]
2005-03-19 13:08 ` p dot obry at wanadoo dot fr
2005-03-19 14:52 ` p dot obry at wanadoo dot fr
2005-03-19 20:54 ` dannysmith at users dot sourceforge dot net
2005-04-06 18:14 ` p dot obry at wanadoo dot fr
2005-04-07  8:29 ` dannysmith at users dot sourceforge dot net
2005-06-16  8:57 ` cvs-commit at gcc dot gnu dot org
2005-06-16  9:11 ` charlet at gcc dot gnu dot org
2005-06-25 12:20 ` dannysmith at users dot sourceforge dot net
2005-06-27 18:50 ` p dot obry at wanadoo dot fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050318042308.21060.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).