This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
divmod-1.c patch (promoting problem)
- To: gcc patches <gcc-patches at gcc dot gnu dot org>
- Subject: divmod-1.c patch (promoting problem)
- From: Aldy Hernandez <aldyh at redhat dot com>
- Date: 21 Aug 2001 16:58:43 +0300
hi guys.
divmod-1.c is failing on -mips2 -mlong64.
signed long
mod5 (x, y)
signed long x, y;
^^^^^^^^^^^^^^^^^^^^ NO PROTOTYPE
{
return x % y;
}
main ()
{
if (mod5 (0x50000000, 2) != 0)
abort ();
since in this case we have 32bit ints but 64bit longs, the arguments to
mod5 (0x50000000 and 2) need to be promoted to 64bits. this is not
happening because in the front end, the code that promotes args
(build_function_call) uses prototype information to determine what to
promote:
/* Convert the parameters to the types declared in the
function prototype, or apply default promotions. */
coerced_params
= convert_arguments (TYPE_ARG_TYPES (fntype), params, name, fundecl);
TYPE_ARG_TYPES() is the prototype information, which in this sample code
we don't have, so convert_arguments() doesn't see type info and assumes
they are ints.
here's a patch to fix the testcase and add the prototypes.
ok to install?
--
Aldy Hernandez E-mail: aldyh@redhat.com
Professional Gypsy and Camel Trader
Red Hat, Inc.
2001-08-21 Aldy Hernandez <aldyh@redhat.com>
* divmod-1.c (mod5): Add prototypes.
(mod6): Likewise.
Index: divmod-1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/gcc.c-torture/execute/divmod-1.c,v
retrieving revision 1.3
diff -c -r1.3 divmod-1.c
*** divmod-1.c 2000/09/21 17:30:11 1.3
--- divmod-1.c 2001/08/21 13:50:17
***************
*** 1,3 ****
--- 1,6 ----
+ signed long mod5 (signed long x, signed long y);
+ unsigned long mod6 (unsigned long x, unsigned long y);
+
div1 (x)
signed char x;
{