https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87689

--- Comment #18 from rguenther at suse dot de <rguenther at suse dot de> ---
On February 13, 2019 6:56:15 AM GMT+01:00, amodra at gmail dot com
<gcc-bugzi...@gcc.gnu.org> wrote:
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87689
>
>--- Comment #17 from Alan Modra <amodra at gmail dot com> ---
>> On platforms where varargs have a different calling
>> signature from normal functions, this would be an ABI change.
>
>True, but in C terms, gfortran is currently doing this:
>void f (char *res, int reslen);
>..
>  f (res, 20, &c, &i1, &i2, &i3, &i4, &i5, &i6);
>That's why I said we have "lying prototypes".
>
>The patch in comment #12 changes things to
>void f (char *res, int reslen, ...);
>..
>  f (res, 20, &c, &i1, &i2, &i3, &i4, &i5, &i6);
>
>Which at least makes the prototype and call compatible in that
>translation
>unit.  

Both indeed look wrong. Afaics if Fortran doesn't require a visible function
definition or declaration it indeed has to build one from the actual call. In
theory it could use a unprototyped function declaration void f() and then use
only a
CALL_EXPR_FNTYPE function type matching the call signature (and hope backends
will be happy with that). That has the advantage of not needing to deal with
mismatches from multiple calls
(multiple decls would be even worse I think) 

We have ABI violations in both cases as neither prototype
>matches the
>actual function definition.  Yes, my patch is just a hack, but..
>
>> It would probably make more sense to build the decl from the call
>> itself.
>This would require major surgery, I think.  Another option would be to
>pass
>info to the backend that the call is really not prototyped despite the
>presence
>of those "hidden" args.
>
>For now, I'm going to post a backend patch for this problem, in
>rs6000_function_parms_need_stack:
>
>  /* FIXME: Fortran arg lists can contain hidden parms, fooling
>     prototype_p into saying the function is prototyped when in fact
>     the number and type of args is unknown.  See PR 87689.  */
>  if (!incoming && (strcmp (lang_hooks.name, "GNU F77") == 0
>                    || lang_GNU_Fortran ()))
>    return true;

Reply via email to