Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Michael Karcher
On 28.01.2016 11:04, Andreas Schwab wrote: > John Paul Adrian Glaubitz writes: > >> [suggestion to use "void" as dummy return type] >> >> Wait. Do you think this would actually allow ghc to determine the >> return type later? If I remember correctly, ghc currently initially >> declares the functio

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Andreas Schwab
Why does the dummy declaration need to use a pointer type? Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Arnaud Charlet
> > package Import is > > > >function Foo return System.Address; > >pragma Import (C, Foo); > > > >function Bar return Integer; > > > > end Import; > > > > package body Import is > > > >function Bar return Integer is > > function Foo_2 return Integer; > > pragma Imp

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Eric Botcazou
> I suspect Ada needs something like this already. I expect the following > to work (although it is quite hideous). > > with System; > > package Import is > >function Foo return System.Address; >pragma Import (C, Foo); > >function Bar return Integer; > > end Import; > > package b

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Richard Biener
On Thu, Jan 28, 2016 at 11:11 AM, Florian Weimer wrote: > On 01/27/2016 04:17 PM, Richard Biener wrote: > >> We are trying to support >> >> t.c >> --- >> void *foo(); >> >> int bar() >> { >> return ((int (*)())foo) (); >> } >> >> t2.c >> - >> int foo () { return 0; } >> >> thus doing a direc

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Florian Weimer
On 01/27/2016 04:17 PM, Richard Biener wrote: > We are trying to support > > t.c > --- > void *foo(); > > int bar() > { > return ((int (*)())foo) (); > } > > t2.c > - > int foo () { return 0; } > > thus doing a direct call to a function with a (wrong) prototype via a function > pointer c

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Andreas Schwab
John Paul Adrian Glaubitz writes: > Wait. Do you think this would actually allow ghc to determine the > return type later? If I remember correctly, ghc currently initially > declares the function prototype with return type void*, doesn't it? Replace a lie with a different lie. Spot the pattern?

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread Andreas Schwab
Richard Biener writes: > I think that's reasonable and what GHC expects - declare "there is a function > foo defined, no idea what prototype yet", unfortunately C requires to specify > a return type. Like void, f.ex. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA

Re: RFC: Support non-standard extension (call via casted function pointer)

2016-01-28 Thread John Paul Adrian Glaubitz
On 01/28/2016 09:55 AM, Andreas Schwab wrote: > Richard Biener writes: > >> I think that's reasonable and what GHC expects - declare "there is a function >> foo defined, no idea what prototype yet", unfortunately C requires to specify >> a return type. > > Like void, f.ex. Wait. Do you think th