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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2cf15adb9e50d90b,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-15 07:36:04 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: reinhold.may@gmx.de (Reinhold May) Newsgroups: comp.lang.ada Subject: Representation Freezing Rules vs. Storage management Date: 15 Apr 2004 07:36:03 -0700 Organization: http://groups.google.com Message-ID: <3202ddcf.0404150636.24cad17b@posting.google.com> NNTP-Posting-Host: 20.138.254.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1082039764 24745 127.0.0.1 (15 Apr 2004 14:36:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Apr 2004 14:36:04 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:7141 Date: 2004-04-15T07:36:03-07:00 List-Id: Hi, I've got a problem with the following code: i : integer; for i'address use get_address(i'size, i'alignment); I've compiled an example featuring this code using the Green Hills Ada compiler without a problem. Gnat fails returning: representation item appears too late Although it makes sense to me that this code compiles (because after all knowing the size of a variable and its alignment is required to find a proper address and thus is probably required in any kind of storage management), after reading some contributions to the newsgroup and the LRM 13.14 (Freezing Rules), I can understand why Gnat doesn't allow me to do it. So my first question is, is the above code legal Ada95 code? If not, does anyone have an idea how I could get the same effect using legal code? I thought about using the type's attributes rather than the variable's ones, like the following: i : integer; for i'address use get_address(integer'size, integer'alignment); My problem is, I'm having to insert this type of representation clause into an existing application (quite a large one). The application has definitions like: a : array(1 .. 10) of integer; which couldn't be used in a representation clause shown above as the type is defined implicitely rather than explicitely. So the type would have to be defined explicitly on each occurrence. The type of a variable is not always easy to find out and trying that would require a full Ada parser (but of course that's feasible). A specific 'size respectively 'alignment clause would have to be recognised and used instead of the type's attributes in order to get the right address (but with the above mentioned parser this would be feasible as well although costing a lot of effort). Any pointer into the right direction is very welcome. Thanks, Reinhold