From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,65f09e2d2d4dad56 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Representation Clauses And Freezing Date: 2000/07/17 Message-ID: #1/1 X-Deja-AN: 647495196 References: <3973192E.E7337814@acm.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov X-Trace: skates.gsfc.nasa.gov 963869465 8930 128.183.220.71 (17 Jul 2000 21:31:05 GMT) Organization: NASA Goddard Space Flight Center Mime-Version: 1.0 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 NNTP-Posting-Date: 17 Jul 2000 21:31:05 GMT Newsgroups: comp.lang.ada Date: 2000-07-17T21:31:05+00:00 List-Id: If you follow the compiler's advice, and change the size and alignment clauses to: for Rec_Type'Size use 16 * System.Storage_Unit; for Rec_Type'Alignment use 4; then it is "happy" again (well, except for all the spaces before the semicolons, but not around elipses :). I have no explanation for why the record size and alignment changes when it is a private type. But why do you care? We've been around on this topic before; the general consensus has been that it is better to define a non-tagged record type that has a rep clause, and include that as a component in a tagged type. -- Stephe "Marin D. Condic" writes: > I am trying to find a reasonable workaround to a problem involving > representation clauses and tagged records. I believe I am running into > problems with freezing rules. Below are two compiler listings which are > very similar. When the record type is visible, the compiler is happy. > When the record type is private, it complains. The question in my mind > is *WHY* is there some sort of restriction on this? What compiler > mission cannot be achieved unless the record is visible? Is there some > sort of workaround that would enable representation clauses on private > tagged records? (Inheritance from a rep-claused-tagged-record is its own > problem!) > > GNAT 3.12p (19990629) Copyright 1992-1999 Free Software Foundation, > Inc. > > Compiling: rep_clause_01.ads (source file time stamp: 2000-07-17 > 14:20:14) > > 1. with System ; > 2. > 3. package Rep_Clause_01 is > 4. > 5. type UInteger_16 is mod 2**16 ; > 6. for UInteger_16'Size use 16 ; > 7. > 8. type Rec_Type is tagged record > 9. Field_01 : Uinteger_16 := 0 ; > 10. Field_02 : Uinteger_16 := 0 ; > 11. Field_03 : Uinteger_16 := 0 ; > 12. end record ; > 13. > 14. private > 15. > 16. for Rec_Type use record > 17. Field_01 at 4 range 0..15 ; > 18. Field_02 at 6 range 0..15 ; > 19. Field_03 at 8 range 0..15 ; > 20. end record ; > 21. > 22. for Rec_Type'Size use 10 * System.Storage_Unit ; > 23. for Rec_Type'Alignment use 2 ; > 24. > 25. end Rep_Clause_01 ; > > 25 lines: No errors > > > GNAT 3.12p (19990629) Copyright 1992-1999 Free Software Foundation, > Inc. > > Compiling: rep_clause_02.ads (source file time stamp: 2000-07-17 > 14:20:14) > > 1. > 2. with System ; > 3. > 4. package Rep_Clause_02 is > 5. > 6. type UInteger_16 is mod 2**16 ; > 7. for UInteger_16'Size use 16 ; > 8. > 9. type Rec_Type is tagged private ; > 10. > 11. private > 12. > 13. type Rec_Type is tagged record > 14. Field_01 : Uinteger_16 := 0 ; > 15. Field_02 : Uinteger_16 := 0 ; > 16. Field_03 : Uinteger_16 := 0 ; > 17. end record ; > 18. > 19. for Rec_Type use record > 20. Field_01 at 4 range 0..15 ; > 21. Field_02 at 6 range 0..15 ; > 22. Field_03 at 8 range 0..15 ; > 23. end record ; > 24. > 25. for Rec_Type'Size use 10 * System.Storage_Unit ; > | > >>> size for "Rec_Type" too small, minimum allowed is 128 > > 26. for Rec_Type'Alignment use 2 ; > | > >>> alignment for "Rec_Type" must be at least 4 > > 27. > 28. end Rep_Clause_02 ; > > > > MDC > -- > ====================================================================== > Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ > Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m > Visit my web site at: http://www.mcondic.com/ > > "Nothing in the world is more dangerous than sincere ignorance and > conscientious stupidity." > > -- Martin Luther King, Jr > ====================================================================== -- -- Stephe