From: xorque on
A discussion arose in #ada on irc.freenode.net about GNAT
requiring the body of a generic unit to be present when
compiling code that uses the generic.

A quote from the Ada 95 issues:

{AI95-00077-01} {AI95-00114-01} {extensions to Ada 83} Ada 83
allowed implementations to require that the body of a generic unit be
available when the instantiation is compiled; that permission is
dropped
in Ada 95. This isn't really an extension (it doesn't allow Ada users
to write
anything that they couldn't in Ada 83), but there isn't a more
appropriate
category, and it does allow users more flexibility when developing
programs.

How come GNAT still requires this?
From: sjw on
On Jan 9, 12:23 pm, xorque <xorquew...(a)googlemail.com> wrote:
> A discussion arose in #ada on irc.freenode.net about GNAT
> requiring the body of a generic unit to be present when
> compiling code that uses the generic.
>
> A quote from the Ada 95 issues:
>
> {AI95-00077-01} {AI95-00114-01} {extensions to Ada 83} Ada 83
> allowed implementations to require that the body of a generic unit be
> available when the instantiation is compiled; that permission is
> dropped
> in Ada 95. This isn't really an extension (it doesn't allow Ada users
> to write
> anything that they couldn't in Ada 83), but there isn't a more
> appropriate
> category, and it does allow users more flexibility when developing
> programs.
>
> How come GNAT still requires this?

AI95-00077-01 Issue 6 starts by saying

"The NOTE in 10.1.4(10), which says that separate compilation of
generic bodies is required, is correct. This implies that an
implementation must be capable of detecting legality errors in a
compilation unit that instantiates a generic unit, without seeing the
generic body. It does not imply that the compiler must generate code
without seeing the generic body."

So compiling with -gnatc (semantic check only) is OK in the absence of
a generic body:

-- The generic body is present, code generation OK
nidhoggr:tests simon$ gnatmake -I../src -c -u -f
collection_test_support.ads
gcc -c -I../src collection_test_support.ads

-- Move the generic body
nidhoggr:tests simon$ mv ../src/bc-containers-collections-
unbounded.adb ../src/bc-containers-collections-unbounded.adb--

-- Code generation fails
nidhoggr:tests simon$ gnatmake -I../src -c -u -f
collection_test_support.ads gcc -c -I../src
collection_test_support.ads
collection_test_support.ads:24:06: body of generic unit "Unbounded"
not found
gnatmake: "collection_test_support.ads" compilation error

-- Semantic checks OK
nidhoggr:tests simon$ gnatmake -I../src -c -u -f
collection_test_support.ads -gnatc
gcc -c -I../src -gnatc collection_test_support.ads