OSDN Git Service

gcc/ada/
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_ch13.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             S E M _ C H 1 3                              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license.          --
20 --                                                                          --
21 -- GNAT was originally developed  by the GNAT team at  New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
23 --                                                                          --
24 ------------------------------------------------------------------------------
25
26 with Types; use Types;
27 with Uintp; use Uintp;
28
29 package Sem_Ch13 is
30    procedure Analyze_At_Clause                          (N : Node_Id);
31    procedure Analyze_Attribute_Definition_Clause        (N : Node_Id);
32    procedure Analyze_Enumeration_Representation_Clause  (N : Node_Id);
33    procedure Analyze_Free_Statement                     (N : Node_Id);
34    procedure Analyze_Record_Representation_Clause       (N : Node_Id);
35    procedure Analyze_Code_Statement                     (N : Node_Id);
36
37    procedure Adjust_Record_For_Reverse_Bit_Order (R : Entity_Id);
38    --  Called from Freeze where R is a record entity for which reverse bit
39    --  order is specified and there is at least one component clause. Adjusts
40    --  component positions according to Ada 2005 AI-133. Note that this is only
41    --  called in Ada 2005 mode. The Ada 95 handling for bit order is entirely
42    --  contained in Freeze.
43
44    procedure Initialize;
45    --  Initialize internal tables for new compilation
46
47    procedure Set_Enum_Esize (T : Entity_Id);
48    --  This routine sets the Esize field for an enumeration type T, based
49    --  on the current representation information available for T. Note that
50    --  the setting of the RM_Size field is not affected. This routine also
51    --  initializes the alignment field to zero.
52
53    function Minimum_Size
54      (T      : Entity_Id;
55       Biased : Boolean := False) return Nat;
56    --  Given an elementary type, determines the minimum number of bits required
57    --  to represent all values of the type. This function may not be called
58    --  with any other types. If the flag Biased is set True, then the minimum
59    --  size calculation that biased representation is used in the case of a
60    --  discrete type, e.g. the range 7..8 gives a minimum size of 4 with
61    --  Biased set to False, and 1 with Biased set to True. Note that the
62    --  biased parameter only has an effect if the type is not biased, it
63    --  causes Minimum_Size to indicate the minimum size of an object with
64    --  the given type, of the size the type would have if it were biased. If
65    --  the type is already biased, then Minimum_Size returns the biased size,
66    --  regardless of the setting of Biased. Also, fixed-point types are never
67    --  biased in the current implementation.
68
69    procedure Check_Constant_Address_Clause (Expr : Node_Id; U_Ent : Entity_Id);
70    --  Expr is an expression for an address clause. This procedure checks
71    --  that the expression is constant, in the limited sense that it is safe
72    --  to evaluate it at the point the object U_Ent is declared, rather than
73    --  at the point of the address clause. The condition for this to be true
74    --  is that the expression has no variables, no constants declared after
75    --  U_Ent, and no calls to non-pure functions. If this condition is not
76    --  met, then an appropriate error message is posted. This check is applied
77    --  at the point an object with an address clause is frozen, as well as for
78    --  address clauses for tasks and entries.
79
80    procedure Check_Size
81      (N      : Node_Id;
82       T      : Entity_Id;
83       Siz    : Uint;
84       Biased : out Boolean);
85    --  Called when size Siz is specified for subtype T. This subprogram checks
86    --  that the size is appropriate, posting errors on node N as required.
87    --  This check is effective for elementary types and bit-packed arrays.
88    --  For other non-elementary types, a check is only made if an explicit
89    --  size has been given for the type (and the specified size must match).
90    --  The parameter Biased is set False if the size specified did not require
91    --  the use of biased representation, and True if biased representation
92    --  was required to meet the size requirement. Note that Biased is only
93    --  set if the type is not currently biased, but biasing it is the only
94    --  way to meet the requirement. If the type is currently biased, then
95    --  this biased size is used in the initial check, and Biased is False.
96    --  If the size is too small, and an error message is given, then both
97    --  Esize and RM_Size are reset to the allowed minimum value in T.
98
99    function Rep_Item_Too_Early (T : Entity_Id; N : Node_Id) return Boolean;
100    --  Called at the start of processing a representation clause or a
101    --  representation pragma. Used to check that the representation item
102    --  is not being applied to an incomplete type or to a generic formal
103    --  type or a type derived from a generic formal type. Returns False if
104    --  no such error occurs. If this error does occur, appropriate error
105    --  messages are posted on node N, and True is returned.
106
107    function Rep_Item_Too_Late
108      (T     : Entity_Id;
109       N     : Node_Id;
110       FOnly : Boolean := False) return Boolean;
111    --  Called at the start of processing a representation clause or a
112    --  representation pragma. Used to check that a representation item
113    --  for entity T does not appear too late (according to the rules in
114    --  RM 13.1(9) and RM 13.1(10)). N is the associated node, which in
115    --  the pragma case is the pragma or representation clause itself, used
116    --  for placing error messages if the item is too late.
117    --
118    --  Fonly is a flag that causes only the freezing rule (para 9) to be
119    --  applied, and the tests of para 10 are skipped. This is appropriate
120    --  for both subtype related attributes (Alignment and Size) and for
121    --  stream attributes, which, although certainly not subtype related
122    --  attributes, clearly should not be subject to the para 10 restrictions
123    --  (see AI95-00137). Similarly, we also skip the para 10 restrictions for
124    --  the Storage_Size case where they also clearly do not apply, and for
125    --  Stream_Convert which is in the same category as the strem attributes.
126    --
127    --  If the rep item is too late, an appropriate message is output and
128    --  True is returned, which is a signal that the caller should abandon
129    --  processing for the item. If the item is not too late, then False
130    --  is returned, and the caller can continue processing the item.
131    --
132    --  If no error is detected, this call also as a side effect links the
133    --  representation item onto the head of the representation item chain
134    --  (referenced by the First_Rep_Item field of the entity).
135    --
136    --  Note: Rep_Item_Too_Late must be called with the underlying type in
137    --  the case of a private or incomplete type. The protocol is to first
138    --  check for Rep_Item_Too_Early using the initial entity, then take the
139    --  underlying type, then call Rep_Item_Too_Late on the result.
140
141    function Same_Representation (Typ1, Typ2 : Entity_Id) return Boolean;
142    --  Given two types, where the two types are related by possible derivation,
143    --  determines if the two types have the same representation, or different
144    --  representations, requiring the special processing for representation
145    --  change. A False result is possible only for array, enumeration or
146    --  record types.
147
148    procedure Validate_Unchecked_Conversion
149      (N        : Node_Id;
150       Act_Unit : Entity_Id);
151    --  Validate a call to unchecked conversion. N is the node for the actual
152    --  instantiation, which is used only for error messages. Act_Unit is the
153    --  entity for the instantiation, from which the actual types etc. for this
154    --  instantiation can be determined. This procedure makes an entry in a
155    --  table and/or generates an N_Validate_Unchecked_Conversion node. The
156    --  actual checking is done in Validate_Unchecked_Conversions or in the
157    --  back end as required.
158
159    procedure Validate_Unchecked_Conversions;
160    --  This routine is called after calling the backend to validate
161    --  unchecked conversions for size and alignment appropriateness.
162    --  The reason it is called that late is to take advantage of any
163    --  back-annotation of size and alignment performed by the backend.
164
165    procedure Validate_Address_Clauses;
166    --  This is called after the back end has been called (and thus after the
167    --  alignments of objects have been back annotated). It goes through the
168    --  table of saved address clauses checking for suspicious alignments and
169    --  if necessary issuing warnings.
170
171 end Sem_Ch13;