comp.lang.ada
 help / color / mirror / Atom feed
* Representation Clauses And Freezing
@ 2000-07-17  0:00 Marin D. Condic
  2000-07-17  0:00 ` Stephen Leake
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Marin D. Condic @ 2000-07-17  0:00 UTC (permalink / raw)


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
======================================================================




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2000-07-24  0:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-17  0:00 Representation Clauses And Freezing Marin D. Condic
2000-07-17  0:00 ` Stephen Leake
2000-07-20  0:00   ` Marin D. Condic
2000-07-20  0:00     ` Stephen Leake
2000-07-21  0:00       ` Marin D. Condic
2000-07-21  0:00         ` Simon Wright
2000-07-22  0:00           ` Marin D. Condic
2000-07-22  0:00             ` tmoran
2000-07-22  0:00               ` Marin D. Condic
2000-07-24  0:00               ` Ted Dennison
2000-07-21  0:00         ` Stephen Leake
2000-07-21  0:00           ` Marin D. Condic
2000-07-21  0:00     ` tmoran
2000-07-18  0:00 ` Nicolas Brunot
2000-07-18  0:00 ` Tucker Taft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox