On Fri, 3 Jan 2014, Richard Biener wrote:
> On Fri, 3 Jan 2014, Jakub Jelinek wrote:
>
> > On Fri, Jan 03, 2014 at 11:15:32AM +0100, Richard Biener wrote:
> > > so if there is a decl then use its type signature, otherwise
> > > (indirect calls) use the caller signature (and hope it matches
> > > the callee...). That it later falls back to looking at
> > > DECL_ARGUMENTS is odd (probably a FE issue where we have a
> > > fndecl with a bogus type?)
> >
> > For K&R C non-prototyped functions
> > foo (x, y)
> > int x, y;
> > {
> > return x + y;
> > }
> > I think TYPE_ARG_TYPES is NULL (?) and DECL_ARGUMENTS is the only way to get
> > at the types.
>
> Ah, indeed. A C speciality that shouldn't survive GENERICization if
> that's really the case.
>
> I wonder how
>
> int main()
> {
> return (*(&foo))(0, 0);
> }
>
> works though. Or
>
> __auto_type x = foo;
>
> (substitute for that new C __auto thing).
>
> The former probably because we fold away the indirection very early.
foo (x, y)
int x, y;
{
return x + y;
}
int main()
{
__auto_type f = foo;
return f(0,0);
}
works just fine for me but shows
int (*<T391>) () f;
int _4;
<bb 2>:
f_1 = foo;
_4 = f_1 (0, 0);
so I suppose the fntype is not NULL but int (*)().
Richard.