This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug translation/15765] New: asmname should be verbatim if starting with an asterisk
- From: "p dot obry at wanadoo dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jun 2004 19:29:57 -0000
- Subject: [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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