public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk
@ 2004-06-01 19:30 p dot obry at wanadoo dot fr
  2004-06-01 19:36 ` [Bug target/15765] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: p dot obry at wanadoo dot fr @ 2004-06-01 19:30 UTC (permalink / raw)
  To: gcc-bugs

On Windows an stdcall calling convention routine will have an @nn suffix and
an '_' prefix added.

If an stdcall symbol starts with an asterisk the underscore prefix is not added
but the @nn suffix is still added in winnt.c (see gen_fastcall_suffix() and
gen_fastcall_suffix() routines).

Even if this following patch looks long the only real change I have made is
to add in both routines:

  /* A symbol starting with an asterisk means that no prefix or suffix must
     be added to this symbol, just return asmname as-is */
  if (asmname[0] == '*')
    return asmname;

I've taken the opportunity to factorize the code in gen_fastcall_suffix() and
gen_stdcall_suffix() as both procedures were having mostly 90% of code
duplication.

<<
*** winnt.c.orig        Sat May 29 15:15:39 2004
--- winnt.c     Sat May 29 15:31:22 2004
***************
*** 403,419 ****
    DECL_NON_ADDR_CONST_P (decl) = 1;
  }

! /* Return string which is the former assembler name modified with a
!    prefix consisting of FASTCALL_PREFIX and a suffix consisting of an
!    atsign (@) followed by the number of bytes of arguments.  */

  static const char *
! gen_fastcall_suffix (tree decl)
  {
    int total = 0;
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;

    if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
      if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
          == void_type_node)
--- 403,424 ----
    DECL_NON_ADDR_CONST_P (decl) = 1;
  }

! /* Return string (using format string) which is the former assembler name
!    modified with a suffix consisting of an atsign (@) followed by the number
!    of bytes of arguments */

  static const char *
! gen_suffix (const char *format, tree decl)
  {
    int total = 0;
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;

+   /* A symbol starting with an asterisk means that no prefix or suffix must
+      be added to this symbol, just return asmname as-is */
+   if (asmname[0] == '*')
+     return asmname;
+
    if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
      if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
          == void_type_node)
***************
*** 438,486 ****

    /* Assume max of 8 base 10 digits in the suffix.  */
    newsym = xmalloc (1 + strlen (asmname) + 1 + 8 + 1);
!   sprintf (newsym, "%c%s@%d", FASTCALL_PREFIX, asmname, total/BITS_PER_UNIT);
    return IDENTIFIER_POINTER (get_identifier (newsym));
  }

  /* Return string which is the former assembler name modified with a
!    suffix consisting of an atsign (@) followed by the number of bytes of
!    arguments */

  static const char *
! gen_stdcall_suffix (tree decl)
  {
!   int total = 0;
!   /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
!      of DECL_ASSEMBLER_NAME.  */
!   const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
!   char *newsym;

!   if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
!     if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
!         == void_type_node)
!       {
!       tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));

!       /* Quit if we hit an incomplete type.  Error is reported
!          by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       while (TREE_VALUE (formal_type) != void_type_node
!              && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))
!         {
!           int parm_size
!             = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
!           /* Must round up to include padding.  This is done the same
!              way as in store_one_arg.  */
!           parm_size = ((parm_size + PARM_BOUNDARY - 1)
!                        / PARM_BOUNDARY * PARM_BOUNDARY);
!           total += parm_size;
!           formal_type = TREE_CHAIN (formal_type);
!         }
!       }

!   /* Assume max of 8 base 10 digits in the suffix.  */
!   newsym = xmalloc (strlen (asmname) + 1 + 8 + 1);
!   sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
!   return IDENTIFIER_POINTER (get_identifier (newsym));
  }

  void
--- 443,473 ----

    /* Assume max of 8 base 10 digits in the suffix.  */
    newsym = xmalloc (1 + strlen (asmname) + 1 + 8 + 1);
!   sprintf (newsym, format, asmname, total/BITS_PER_UNIT);
    return IDENTIFIER_POINTER (get_identifier (newsym));
  }

  /* Return string which is the former assembler name modified with a
!    prefix consisting of FASTCALL_PREFIX and a suffix consisting of an
!    atsign (@) followed by the number of bytes of arguments.  */

  static const char *
! gen_fastcall_suffix (tree decl)
  {
!   char *format = " %s@%d";
!   format[0] = FASTCALL_PREFIX;

!   return gen_suffix (format, decl);
! }

! /* Return string which is the former assembler name modified with a
!    suffix consisting of an atsign (@) followed by the number of bytes of
!    arguments */

! static const char *
! gen_stdcall_suffix (tree decl)
! {
!   return gen_suffix ("%s@%d", decl);
  }

  void
>>

Pascal.

-- 
           Summary: asmname should be verbatim if starting with an asterisk
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: translation
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: p dot obry at wanadoo dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: pentium-mingw32msv
  GCC host triplet: pentium-mingw32msv
GCC target triplet: pentium-mingw32msv


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/15765] asmname should be verbatim if starting with an asterisk
  2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
@ 2004-06-01 19:36 ` pinskia at gcc dot gnu dot org
  2004-06-02  8:49 ` p dot obry at wanadoo dot fr
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-01 19:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-01 19:36 -------
patches go to gcc-patches@ after reading http://gcc.gnu.org/contribute.html.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|translation                 |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/15765] asmname should be verbatim if starting with an asterisk
  2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
  2004-06-01 19:36 ` [Bug target/15765] " pinskia at gcc dot gnu dot org
@ 2004-06-02  8:49 ` p dot obry at wanadoo dot fr
  2004-06-02 11:39 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: p dot obry at wanadoo dot fr @ 2004-06-02  8:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From p dot obry at wanadoo dot fr  2004-06-02 08:49 -------
Does that means I have to send the patch to gcc-patches@ ?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/15765] asmname should be verbatim if starting with an asterisk
  2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
  2004-06-01 19:36 ` [Bug target/15765] " pinskia at gcc dot gnu dot org
  2004-06-02  8:49 ` p dot obry at wanadoo dot fr
@ 2004-06-02 11:39 ` pinskia at gcc dot gnu dot org
  2004-06-02 20:07 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-02 11:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-02 11:39 -------
yes you have to send it to gcc-patches@, almost none of the approvers will look into bug reports to 
look for patches.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/15765] asmname should be verbatim if starting with an asterisk
  2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
                   ` (2 preceding siblings ...)
  2004-06-02 11:39 ` pinskia at gcc dot gnu dot org
@ 2004-06-02 20:07 ` pinskia at gcc dot gnu dot org
  2004-09-24  9:18 ` dannysmith at users dot sourceforge dot net
  2004-09-27  3:46 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-02 20:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-02 20:06 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00131.html>.
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |patch, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-02 20:06:59
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/15765] asmname should be verbatim if starting with an asterisk
  2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
                   ` (3 preceding siblings ...)
  2004-06-02 20:07 ` pinskia at gcc dot gnu dot org
@ 2004-09-24  9:18 ` dannysmith at users dot sourceforge dot net
  2004-09-27  3:46 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2004-09-24  9:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dannysmith at users dot sourceforge dot net  2004-09-24 09:17 -------
This has been fixed on trunk by a patch for another PR:

2004-08-21  Danny Smith  <dannysmith@users.sourceforge.net>

	PR  c++/16030
	* config/i386/winnt/c (gen_stdcall_suffix, gen_fastcall_suffix):
	Remove, merging into ...
	(gen_stdcall_or_fastcall_suffix): New function, returning tree
	rather than const char*, and accepting additional parameter.
	Don't add suffix to '*'-prefixed symbols or variadic functions.
	(i386_pe_encode_section_info): Adjust for call to new function.
	Call change_decl_assembler_name.

Note, now that this has been fixed, the following in gnat_ugn.texi
is no longer accurate.

  @smallexample @c ada
  @group
  function Get_Val (V : Interfaces.C.long) return Interfaces.C.int;
  pragma Import (Stdcall, Get_Val, Link_Name => "retrieve_val");
  @end group
  @end smallexample

  @noindent
  then the imported routine is @code{retrieve_val@@4}, that is, there is no
  trailing underscore but the appropriate @code{@@}@code{@i{nn}} is always
  added at the end of the @code{Link_Name} by the compiler.

This example now produces the unresolved name
	U retrieve_val

with no decoration at all. 

Danny

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/15765] asmname should be verbatim if starting with an asterisk
  2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
                   ` (4 preceding siblings ...)
  2004-09-24  9:18 ` dannysmith at users dot sourceforge dot net
@ 2004-09-27  3:46 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-27  3:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-27 03:46 -------
Patch is no longer needed, this is only open for the documentation change that is needed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-09-27  3:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
2004-06-01 19:36 ` [Bug target/15765] " pinskia at gcc dot gnu dot org
2004-06-02  8:49 ` p dot obry at wanadoo dot fr
2004-06-02 11:39 ` pinskia at gcc dot gnu dot org
2004-06-02 20:07 ` pinskia at gcc dot gnu dot org
2004-09-24  9:18 ` dannysmith at users dot sourceforge dot net
2004-09-27  3:46 ` pinskia at gcc dot gnu dot org

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