This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
gcc/config/i386/i386.c patch
- To: egcs-patches at cygnus dot com
- Subject: gcc/config/i386/i386.c patch
- From: Marcus Meissner (CIP 91 - Stud) <Marcus dot Meissner at informatik dot uni-erlangen dot de>
- Date: Fri, 16 Oct 1998 23:43:07 +0200 (MET DST)
Hi,
I define this to be a small change, which does not require the copyright
buerocratics.
Bug in egcs/gcc:
gcc could not detect mismatch of presence of
__attribute__(("stdcall")) (or "cdecl") between function declaration
and definition.
How the patch fixes the bug:
it looks up the attribute which is not the default (as checked by
TARGET_RTD) and compares presence indicators between definition
and declaration.
Changelog:
Handle mismatched attributes "stdcall" and "cdecl" between
function definition and declaration (which leads to mysterious
stackcorruption in programs using this mixed, like WINE).
Ciao, Marcus
PS: I do not read any mailing list related to egcs.
Index: i386.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.43
diff -c -3 -p -r1.43 i386.c
*** i386.c 1998/10/12 10:06:49 1.43
--- i386.c 1998/10/16 21:40:51
*************** i386_valid_type_attribute_p (type, attri
*** 622,630 ****
int
i386_comp_type_attributes (type1, type2)
! tree type1 ATTRIBUTE_UNUSED;
! tree type2 ATTRIBUTE_UNUSED;
{
return 1;
}
--- 622,642 ----
int
i386_comp_type_attributes (type1, type2)
! tree type1;
! tree type2;
{
+ /* Check for mismatch of non-default calling convention. */
+ int rtd = TARGET_RTD;
+ char *rtdstr = rtd ? "cdecl" : "stdcall";
+
+ if ((TREE_CODE(type1)!=FUNCTION_TYPE))
+ return 1;
+
+ /* Check for mismatched returntypes (cdecl vs stdcall). */
+ if ((0!=lookup_attribute (rtdstr, TYPE_ATTRIBUTES (type1))) !=
+ (0!=lookup_attribute (rtdstr, TYPE_ATTRIBUTES (type2)))
+ )
+ return 0;
return 1;
}