OSDN Git Service

f8e85b3c02ad6a99d4791a4c473c1be2fe770b61
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_ch2.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              S E M _ C H 2                               --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                            $Revision: 1.8 $                              --
10 --                                                                          --
11 --          Copyright (C) 1992-1999, Free Software Foundation, Inc.         --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28
29 with Atree;    use Atree;
30 with Opt;      use Opt;
31 with Restrict; use Restrict;
32 with Sem_Ch8;  use Sem_Ch8;
33 with Sinfo;    use Sinfo;
34 with Stand;    use Stand;
35
36 package body Sem_Ch2 is
37
38    -------------------------------
39    -- Analyze_Character_Literal --
40    -------------------------------
41
42    procedure Analyze_Character_Literal (N : Node_Id) is
43    begin
44
45       --  The type is eventually inherited from the context. If expansion
46       --  has already established the proper type, do not modify it.
47
48       if No (Etype (N)) then
49          Set_Etype (N, Any_Character);
50       end if;
51
52       Set_Is_Static_Expression (N);
53
54       if Comes_From_Source (N)
55         and then not In_Character_Range (Char_Literal_Value (N))
56       then
57          Check_Restriction (No_Wide_Characters, N);
58       end if;
59    end Analyze_Character_Literal;
60
61    ------------------------
62    -- Analyze_Identifier --
63    ------------------------
64
65    procedure Analyze_Identifier (N : Node_Id) is
66    begin
67       Find_Direct_Name (N);
68    end Analyze_Identifier;
69
70    -----------------------------
71    -- Analyze_Integer_Literal --
72    -----------------------------
73
74    procedure Analyze_Integer_Literal (N : Node_Id) is
75    begin
76       Set_Etype (N, Universal_Integer);
77       Set_Is_Static_Expression (N);
78    end Analyze_Integer_Literal;
79
80    --------------------------
81    -- Analyze_Real_Literal --
82    --------------------------
83
84    procedure Analyze_Real_Literal (N : Node_Id) is
85    begin
86       Set_Etype (N, Universal_Real);
87       Set_Is_Static_Expression (N);
88    end Analyze_Real_Literal;
89
90    ----------------------------
91    -- Analyze_String_Literal --
92    ----------------------------
93
94    procedure Analyze_String_Literal (N : Node_Id) is
95    begin
96
97       --  The type is eventually inherited from the context. If expansion
98       --  has already established the proper type, do not modify it.
99
100       if No (Etype (N)) then
101          Set_Etype (N, Any_String);
102       end if;
103
104       --  String literals are static in Ada 95. Note that if the subtype
105       --  turns out to be non-static, then the Is_Static_Expression flag
106       --  will be reset in Eval_String_Literal.
107
108       if Ada_95 then
109          Set_Is_Static_Expression (N);
110       end if;
111
112       if Comes_From_Source (N) and then Has_Wide_Character (N) then
113          Check_Restriction (No_Wide_Characters, N);
114       end if;
115    end Analyze_String_Literal;
116
117 end Sem_Ch2;