* Re: Odd error with access to derived types
[not found] <feusm0hpbe5frsvljam7jbllqvftusc10v@4ax.com>
@ 2004-10-14 19:17 ` Niklas Holsti
2004-10-15 1:28 ` Stephen Leake
1 sibling, 0 replies; 7+ messages in thread
From: Niklas Holsti @ 2004-10-14 19:17 UTC (permalink / raw)
A. Imran wrote:
> Hello,
>
> I'm getting a very odd error from my compiler (GNAT 3.15p, also tried
> the latest GCC based GNAT).
>
> Would anyone point out why the following is / is not valid ada? TIA.
The following works for me with GNAT 3.15p, Debian:
package testp is
type a_type is tagged record
foo : natural;
end record;
end testp;
package testp.b is
type b_type is new a_type with private;
type b_access is access all b_type;
private
type b_type is new a_type with record
dummy : boolean;
end record;
end testp.b;
Did I misunderstand which variant of your code fails?
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
>
> -- begin testp-b.adb --
> package testp.b is
>
> -- TO FAIL: Comment the next line and leave
> -- the line after that uncommented.
>
> -- XXX 0
> -- type b_type is new a_type with null record;
> type b_type is new a_type with private;
>
> type b_access is access all b_type;
>
> private
>
> -- TO FAIL: Keep the following uncommented
> -- XXX 1
> type b_type is new a_type with record
> dummy : boolean;
> end record;
>
> end testp.b;
> -- end testp-b.adb --
>
> I'm getting an error that says that the definition of the private type
> (XXX 1) conflicts with the access type (XXX 0). Any ideas?
>
>
>
> Here is the rest of the code:
>
> -- begin testp.adb --
> package testp is
>
> task type a_task;
>
> type a_type is abstract tagged limited record
> dummy_task : a_task;
> end record;
>
> end testp;
> -- end testp.adb --
>
> -- begin test.adb --
> -- Just used for compiling library units
> with testp;
> with testp.b;
>
> procedure test is
> begin
> null;
> end test;
> -- end test.adb --
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd error with access to derived types
[not found] <feusm0hpbe5frsvljam7jbllqvftusc10v@4ax.com>
2004-10-14 19:17 ` Odd error with access to derived types Niklas Holsti
@ 2004-10-15 1:28 ` Stephen Leake
2004-10-16 0:30 ` A. Imran
1 sibling, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2004-10-15 1:28 UTC (permalink / raw)
To: comp.lang.ada
A.Imran <me5@privacy.net> writes:
> Hello,
>
> I'm getting a very odd error from my compiler (GNAT 3.15p, also tried
> the latest GCC based GNAT).
>
> Would anyone point out why the following is / is not valid ada? TIA.
I get this:
gnatmake -k -g -O0 -gnatf -gnato -gnatwa -gnatwe -gnatwL -gnatVa -I.. test -largs -bargs -E -cargs
gcc -c -I./ -g -O0 -gnatf -gnato -gnatwa -gnatwe -gnatwL -gnatVa -I.. -I- ..\test.adb
test.adb:1:11: warning: unit "b" is not referenced
testp-b.ads:7:10: "b_type" conflicts with declaration at line 6
testp-b.ads:15:10: completion of nonlimited type cannot be limited
you are declaring 'b_type' twice. But perhaps that's not what you
meant. Perhaps you meant "I get an error with the second definition of
b_type". But I'm not going to guess. Please post _exactly_ the code
that generates the error, so we can help.
>
> -- begin testp-b.adb --
> package testp.b is
>
> -- TO FAIL: Comment the next line and leave
> -- the line after that uncommented.
>
> -- XXX 0
Is this the line you want uncommented? I don't think so.
> -- type b_type is new a_type with null record;
> type b_type is new a_type with private;
Did you want both definitions of 'b_type'? I don't think so.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd error with access to derived types
2004-10-15 1:28 ` Stephen Leake
@ 2004-10-16 0:30 ` A. Imran
2004-10-16 12:58 ` Stephen Leake
0 siblings, 1 reply; 7+ messages in thread
From: A. Imran @ 2004-10-16 0:30 UTC (permalink / raw)
Thank you for looking at the code. Here is the error message:
~> gnatmake test
gcc -c test.adb
parent-child.ads:10:09: "derived_access" conflicts with declaration at
line 6
gnatmake: "test.adb" compilation error
Relevant lines from parent-child.ads:
6 type derived_access is access all derived_type;
10 type derived_type is new base_type with record
11 dummy : boolean;
12 end record;
Complete code:
package parent is
task type a_task;
type base_type is abstract tagged limited record
dummy_task : a_task;
end record;
end parent;
package parent.child is
type derived_type is new base_type with private;
type derived_access is access all derived_type;
private
type derived_type is new base_type with record
dummy : boolean;
end record;
end parent.child;
The driver I use to compile the code:
with parent;
with parent.child;
procedure test is
begin
null;
end test;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd error with access to derived types
2004-10-16 0:30 ` A. Imran
@ 2004-10-16 12:58 ` Stephen Leake
2004-10-17 0:19 ` Brian May
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2004-10-16 12:58 UTC (permalink / raw)
To: comp.lang.ada
A.Imran <me5@privacy.net> writes:
> Thank you for looking at the code. Here is the error message:
>
> ~> gnatmake test
> gcc -c test.adb
> parent-child.ads:10:09: "derived_access" conflicts with declaration at
> line 6
> gnatmake: "test.adb" compilation error
That is certainly a confusing error message. I'd call it a compiler
bug; submit this to report@gnat.com.
As for working around it, this compiles:
package parent is
task type a_task;
type base_type is abstract tagged limited record
dummy_task : a_task;
end record;
type Task_Access is access Base_Type'Class;
end parent;
package parent.child is
type derived_type is new base_type with private;
-- type Derived_Access is access derived_type;
private
type derived_type is new base_type with record
dummy : boolean;
end record;
end parent.child;
with parent.child;
procedure test
is
My_Task : Parent.Task_Access := new Parent.Child.Derived_Type;
begin
null;
end test;
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd error with access to derived types
2004-10-16 12:58 ` Stephen Leake
@ 2004-10-17 0:19 ` Brian May
2004-10-17 0:32 ` Stephen Leake
0 siblings, 1 reply; 7+ messages in thread
From: Brian May @ 2004-10-17 0:19 UTC (permalink / raw)
>>>>> "Stephen" == Stephen Leake <stephen_leake@acm.org> writes:
Stephen> A.Imran <me5@privacy.net> writes:
>> Thank you for looking at the code. Here is the error message:
>>
>> ~> gnatmake test gcc -c test.adb parent-child.ads:10:09:
>> "derived_access" conflicts with declaration at line 6 gnatmake:
>> "test.adb" compilation error
Stephen> That is certainly a confusing error message. I'd call it
Stephen> a compiler bug; submit this to report@gnat.com.
Was the previous code valid? If not, why not?
Stephen> As for working around it, this compiles: package parent
Stephen> is
Another three work arounds I found:
a) move definition of derived_access after derived_type (i.e. make it private).
b) make definition of derived_type public.
It would appear that derived_access needs the full definition of
derived_type in order to work because it contains a task. I don't
understand why.
c) make dummy_task an access type to a_task.
My preference would be c), although you could argue you shouldn't need
to use or manipulate access types here.
gcc-3.4 also has the same problem:
[519] [snoopy:bam] ~/abc >gnatmake test
gcc-3.4 -c test.adb
parent-child.ads:9:09: "derived_access" conflicts with declaration at line 5
gnatmake: "test.adb" compilation error
--
Brian May <bam@snoopy.apana.org.au>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd error with access to derived types
2004-10-17 0:19 ` Brian May
@ 2004-10-17 0:32 ` Stephen Leake
2004-10-17 12:14 ` A. Imran
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2004-10-17 0:32 UTC (permalink / raw)
To: comp.lang.ada
Brian May <bam@snoopy.apana.org.au> writes:
> >>>>> "Stephen" == Stephen Leake <stephen_leake@acm.org> writes:
>
> Stephen> A.Imran <me5@privacy.net> writes:
> >> Thank you for looking at the code. Here is the error message:
> >>
> >> ~> gnatmake test gcc -c test.adb parent-child.ads:10:09:
> >> "derived_access" conflicts with declaration at line 6 gnatmake:
> >> "test.adb" compilation error
>
> Stephen> That is certainly a confusing error message. I'd call it
> Stephen> a compiler bug; submit this to report@gnat.com.
>
> Was the previous code valid? If not, why not?
I don't know.
> <snip>
>
> It would appear that derived_access needs the full definition of
> derived_type in order to work because it contains a task. I don't
> understand why.
This probably has something to do with "freezing rules", which are
notoriously tricky.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-10-17 12:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <feusm0hpbe5frsvljam7jbllqvftusc10v@4ax.com>
2004-10-14 19:17 ` Odd error with access to derived types Niklas Holsti
2004-10-15 1:28 ` Stephen Leake
2004-10-16 0:30 ` A. Imran
2004-10-16 12:58 ` Stephen Leake
2004-10-17 0:19 ` Brian May
2004-10-17 0:32 ` Stephen Leake
2004-10-17 12:14 ` A. Imran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox