* -fdump-ada-spec
@ 2014-10-06 17:45 Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-06 17:45 UTC (permalink / raw)
Does anyone know where this is implemented in the GCC sources?
I'm having trouble with some of the system headers: on Mac OS X, with
all the GNATs and GCCs I have, dumping /usr/include/wchar.h uses
'limited with' in a way that doesn't work, whereas on Debian (wheezy,
gcc-4.7) there's no 'limited with'. Of course, wchar.h is different!
I _think_ that -fdump-ada-spec sees that a particular type (eg FILE) is
always accessed via a pointer, and decides that 'limited with' is OK;
but for some reason this ends up being unacceptable.
The ARM (and AI95-0217) didn't help a lot here. I think the problem is
that the original code is like
typedef struct Blah {
int x;
} FILE;
and the generated code is like
package Stdio is
type Blah is record
X : Integer;
end record;
subtype FILE is Blah;
end Stdio;
limited with Stdio;
package Wchar is
procedure Foo (F : access Stdio.FILE);
end Wchar;
and the 'limited with' magic only works for _types_, so you get the
error '"FILE" not declared in "Stdio"'.
Stdio.FILE should be declared as
type FILE is new Blah;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-06 17:45 -fdump-ada-spec Simon Wright
@ 2014-10-07 14:08 ` Stephen Leake
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
2014-10-10 10:06 ` -fdump-ada-spec Simon Wright
2 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2014-10-07 14:08 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> Does anyone know where this is implemented in the GCC sources?
I don't; I guess you want to develop a patch?
> <snip>
>
> and the 'limited with' magic only works for _types_, so you get the
> error '"FILE" not declared in "Stdio"'.
>
> Stdio.FILE should be declared as
>
> type FILE is new Blah;
As a workaround, you can maintain a patch for the generated code, and
apply it in your Makefile.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-06 17:45 -fdump-ada-spec Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
@ 2014-10-07 15:12 ` Markus Schöpflin
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-10 10:06 ` -fdump-ada-spec Simon Wright
2 siblings, 1 reply; 7+ messages in thread
From: Markus Schöpflin @ 2014-10-07 15:12 UTC (permalink / raw)
Am 06.10.2014 19:45, schrieb Simon Wright:
> Does anyone know where this is implemented in the GCC sources?
The patch implementing -fdump-ada-spec can be found here:
https://gcc.gnu.org/ml/gcc-patches/2010-04/msg01592.html
The diff should give you a precise idea where to look. :-)
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
@ 2014-10-07 16:05 ` Simon Wright
0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-07 16:05 UTC (permalink / raw)
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> Simon Wright <simon@pushface.org> writes:
>
>> Does anyone know where this is implemented in the GCC sources?
>
> I don't; I guess you want to develop a patch?
Not really; just to understand it better!
For example, you may have taken the online manual's remark "C++ classes
will be mapped to Ada tagged types" as gospel; it turns out that this
only happens for C++ classes with virtual methods. I think.
>> <snip>
>>
>> and the 'limited with' magic only works for _types_, so you get the
>> error '"FILE" not declared in "Stdio"'.
>>
>> Stdio.FILE should be declared as
>>
>> type FILE is new Blah;
Thinking about it, that doesn't match the 'semantics' of typedef.
> As a workaround, you can maintain a patch for the generated code, and
> apply it in your Makefile.
Actually, an editor script to change 'limited with' to plain 'with'
would sort this one out nicely.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
@ 2014-10-07 16:05 ` Simon Wright
0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-07 16:05 UTC (permalink / raw)
Markus Schöpflin <no.spam@spam.spam> writes:
> Am 06.10.2014 19:45, schrieb Simon Wright:
>
>> Does anyone know where this is implemented in the GCC sources?
>
> The patch implementing -fdump-ada-spec can be found here:
> https://gcc.gnu.org/ml/gcc-patches/2010-04/msg01592.html
>
> The diff should give you a precise idea where to look. :-)
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-08 19:14 ` -fdump-ada-spec (was: Newcomers to comp.lang.ada: welcome and how did you end up here ?) Ludovic Brenta
@ 2014-10-08 19:48 ` Simon Wright
0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-08 19:48 UTC (permalink / raw)
Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>> Apparently one should use g++ rather than gcc, because it makes a better
>> job of it.
>>
>> GNAT GPL 2014 does translate (some) macros; it doesn't always get it
>> right, eg
>>
>> #define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
>> #define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
>> #define MAXFLOAT 0x1.fffffep+127f
>>
>> // have to have _something_ besides the constants or no .ads gets
>> // generated.
>> extern float sinf(float);
>>
>> turns into
>>
>> pragma Ada_2005;
>> pragma Style_Checks (Off);
>>
>> with Interfaces.C; use Interfaces.C;
>>
>> package math_h is
>>
>>
>> M_SQRT2 : constant := 1.41421356237309504880168872420969808; -- ./math.h:1
>> M_SQRT1_2 : constant := 8#.707106781186547524400844362104849039#; -- ./math.h:2
> ^^ ^
>
> Isn't that a blatant bug? Either in the Ada or in the C source?
Yes; like I said, it doesn't always get it right.
And it doesn't understand hex floats either: 16#1.fffffep+127f# is *not*
a good translation of 0x1.fffffep+127f !
I have reported these problems to AdaCore, but as they have always said
the translation isn't expected to be perfect, so it'll be very low on
their priority list.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-06 17:45 -fdump-ada-spec Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
@ 2014-10-10 10:06 ` Simon Wright
2 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-10 10:06 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> I'm having trouble with some of the system headers: on Mac OS X, with
> all the GNATs and GCCs I have, dumping /usr/include/wchar.h uses
> 'limited with' in a way that doesn't work, whereas on Debian (wheezy,
> gcc-4.7) there's no 'limited with'. Of course, wchar.h is different!
I'm told that this falls under "this capability is not intended to
generate 100% correct Ada specs".
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-10 10:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 17:45 -fdump-ada-spec Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-10 10:06 ` -fdump-ada-spec Simon Wright
-- strict thread matches above, loose matches on Subject: below --
2014-10-06 22:42 Newcomers to comp.lang.ada: welcome and how did you end up here ? Simon Clubley
2014-10-07 8:10 ` Gour
2014-10-07 10:49 ` Luke A. Guest
2014-10-08 7:23 ` Gour
2014-10-08 8:35 ` Brian Drummond
2014-10-08 9:15 ` Simon Wright
2014-10-08 19:14 ` -fdump-ada-spec (was: Newcomers to comp.lang.ada: welcome and how did you end up here ?) Ludovic Brenta
2014-10-08 19:48 ` -fdump-ada-spec Simon Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox