OSDN Git Service

* Makefile.in (reload1.o-warn): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / ada / itypes.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               I T Y P E S                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2005, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package contains declarations for handling of implicit types
28
29 with Einfo;    use Einfo;
30 with Sem_Util; use Sem_Util;
31 with Types;    use Types;
32
33 package Itypes is
34
35    --------------------
36    -- Implicit Types --
37    --------------------
38
39    --  Implicit types are types and subtypes created by the semantic phase
40    --  or the expander to reflect the underlying semantics. These could be
41    --  generated by building trees for corresponding declarations and then
42    --  analyzing these trees, but there are three reasons for not doing this:
43
44    --    1. The declarations would require more tree nodes
45
46    --    2. In some cases, the elaboration of these types is associated
47    --       with internal nodes in the tree.
48
49    --    3. For some types, notably class wide types, there is no Ada
50    --       declaration that would correspond to the desired entity.
51
52    --  So instead, implicit types are constructed by simply creating an
53    --  appropriate entity with the help of routines in this package. These
54    --  entities are fully decorated, as described in Einfo (just as though
55    --  they had been created by the normal analysis procedure).
56
57    --  The type declaration declaring an Itype must be analyzed with checks
58    --  off because this declaration has not been inserted in the tree (if it
59    --  has been then it is not an itype), and hence checks that would be
60    --  generated during the analysis cannot be inserted in the tree. At any
61    --  rate, itype analysis should always be done with checks off, otherwise
62    --  duplicate checks will most likely be emitted.
63
64    --  Unlike types declared explicitly, implicit types are defined on first
65    --  use, which means that Gigi detects the use of such types, and defines
66    --  them at the point of the first use automatically.
67
68    --  Although Itypes are not explicitly declared, they are associated with
69    --  a specific node in the tree (roughly the node that caused them to be
70    --  created), via the Associated_Node_For_Itype field. This association is
71    --  used particularly by New_Copy_Tree, which uses it to determine whether
72    --  or not to copy a referenced Itype. If the associated node is part of
73    --  the tree to be copied by New_Copy_Tree, then (since the idea of the
74    --  call to New_Copy_Tree is to create a complete duplicate of a tree,
75    --  as though it had appeared separately in the source), the Itype in
76    --  question is duplicated as part of the New_Copy_Tree processing.
77
78    -----------------
79    -- Subprograms --
80    -----------------
81
82    function Create_Itype
83      (Ekind        : Entity_Kind;
84       Related_Nod  : Node_Id;
85       Related_Id   : Entity_Id := Empty;
86       Suffix       : Character := ' ';
87       Suffix_Index : Nat       := 0;
88       Scope_Id     : Entity_Id := Current_Scope) return Entity_Id;
89    --  Used to create a new Itype.
90    --
91    --   Related_Nod is the node for which this Itype was created.  It is
92    --   set as the Associated_Node_For_Itype of the new itype.  The Sloc of
93    --   the new Itype is that of this node.
94    --
95    --   Related_Id is present only if the implicit type name may be referenced
96    --   as a public symbol, and thus needs a unique external name. The name
97    --   is created by a call to:
98    --
99    --     New_External_Name (Chars (Related_Id), Suffix, Suffix_Index, 'T')
100    --
101    --   If the implicit type does not need an external name, then the
102    --   Related_Id parameter is omitted (and hence Empty). In this case
103    --   Suffix and Suffix_Index are ignored and the implicit type name is
104    --   created by a call to New_Internal_Name ('T').
105    --
106    --   Note that in all cases, the name starts with "T". This is used
107    --   to identify implicit types in the error message handling circuits.
108    --
109    --  The Scope_Id parameter specifies the scope of the created type, and
110    --  is normally the Current_Scope as shown, but can be set otherwise.
111
112    ---------------------------------
113    -- Create_Null_Excluding_Itype --
114    ---------------------------------
115
116    function Create_Null_Excluding_Itype
117       (T           : Entity_Id;
118        Related_Nod : Node_Id;
119        Scope_Id    : Entity_Id := Current_Scope) return Entity_Id;
120    --  Ada 2005 (AI-231): T is an access type and this subprogram creates and
121    --  returns an internal access-subtype declaration of T that has the null
122    --  exclusion attribute set to True.
123    --
124    --  Usage of null-excluding itypes
125    --  ------------------------------
126    --
127    --      type T1 is access ...
128    --      type T2 is not null T1;
129    --
130    --      type Rec is record
131    --         Comp : not null T1;
132    --      end record;
133    --
134    --      type Arr is array (...) of not null T1;
135    --
136    --  Instead of associating the not-null attribute with the defining ids of
137    --  these declarations, we generate an internal subtype declaration of T1
138    --  that has the null exclusion attribute set to true.
139
140 end Itypes;