On 7/8/07, Kaveh R. GHAZI <[EMAIL PROTECTED]> wrote:
On Sat, 7 Jul 2007, Joseph S. Myers wrote:

> No, that's something else entirely (a "float" old-style parameter
> declaration corresponds to a "double" argument in a prototype).  It's
> convert_arguments that handles converting to prototype types and default
> argument promotions for arguments not covered by a prototype (including
> those in the ... of a variadic function).
>
>       else if (TREE_CODE (TREE_TYPE (val)) == REAL_TYPE
>                && (TYPE_PRECISION (TREE_TYPE (val))
>                    < TYPE_PRECISION (double_type_node))
>                && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (val))))
>         /* Convert `float' to `double'.  */
>         argarray[parmnum] = convert (double_type_node, val);


Ah perfect, thanks.  I'm thinking something like what's below.  I'll move
it over to gcc-patches and add a ChangeLog if it passes testing.

Thanks for your help!

                --Kaveh


diff -rup orig/egcc-SVN20070706/gcc/c-typeck.c egcc-SVN20070706/gcc/c-typeck.c
--- orig/egcc-SVN20070706/gcc/c-typeck.c        2007-06-30 23:02:59.000000000 
-0400
+++ egcc-SVN20070706/gcc/c-typeck.c     2007-07-07 21:26:33.982197838 -0400
@@ -2394,6 +2394,8 @@ convert_arguments (int nargs, tree *arga
 {
   tree typetail, valtail;
   int parmnum;
+  const bool type_generic =
+    !!lookup_attribute ("type generic", TYPE_ATTRIBUTES(TREE_TYPE (fundecl)));
   tree selector;

   /* Change pointer to function to the function itself for
@@ -2585,8 +2587,13 @@ convert_arguments (int nargs, tree *arga
               && (TYPE_PRECISION (TREE_TYPE (val))
                   < TYPE_PRECISION (double_type_node))
               && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (val))))
-       /* Convert `float' to `double'.  */
-       argarray[parmnum] = convert (double_type_node, val);
+        {
+         /* Convert `float' to `double'.  */
+         if (type_generic)
+           argarray[parmnum] = val;
+         else
+           argarray[parmnum] = convert (double_type_node, val);
+       }
       else if ((invalid_func_diag =
                targetm.calls.invalid_arg_for_unprototyped_fn (typelist, 
fundecl, val)))
        {

So type-generic is supposed to apply to scalar floating point types
only?  Btw. you need to add documentation for this function attribute.

Richard.

Reply via email to