41intnam.ads, [...]: Merge in ACT changes.
[gcc.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$
10 -- --
11 -- Copyright (C) 1992-2001, 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 Errout; use Errout;
31 with Opt; use Opt;
32 with Restrict; use Restrict;
33 with Sem_Ch8; use Sem_Ch8;
34 with Sinfo; use Sinfo;
35 with Stand; use Stand;
36
37 package body Sem_Ch2 is
38
39 -------------------------------
40 -- Analyze_Character_Literal --
41 -------------------------------
42
43 procedure Analyze_Character_Literal (N : Node_Id) is
44 begin
45
46 -- The type is eventually inherited from the context. If expansion
47 -- has already established the proper type, do not modify it.
48
49 if No (Etype (N)) then
50 Set_Etype (N, Any_Character);
51 end if;
52
53 Set_Is_Static_Expression (N);
54
55 if Comes_From_Source (N)
56 and then not In_Character_Range (Char_Literal_Value (N))
57 then
58 Check_Restriction (No_Wide_Characters, N);
59 end if;
60 end Analyze_Character_Literal;
61
62 ------------------------
63 -- Analyze_Identifier --
64 ------------------------
65
66 procedure Analyze_Identifier (N : Node_Id) is
67 begin
68 -- Ignore call if prior errors, and identifier has no name, since
69 -- this is the result of some kind of previous error generating a
70 -- junk identifier.
71
72 if Chars (N) in Error_Name_Or_No_Name
73 and then Total_Errors_Detected /= 0
74 then
75 return;
76 else
77 Find_Direct_Name (N);
78 end if;
79 end Analyze_Identifier;
80
81 -----------------------------
82 -- Analyze_Integer_Literal --
83 -----------------------------
84
85 procedure Analyze_Integer_Literal (N : Node_Id) is
86 begin
87 Set_Etype (N, Universal_Integer);
88 Set_Is_Static_Expression (N);
89 end Analyze_Integer_Literal;
90
91 --------------------------
92 -- Analyze_Real_Literal --
93 --------------------------
94
95 procedure Analyze_Real_Literal (N : Node_Id) is
96 begin
97 Set_Etype (N, Universal_Real);
98 Set_Is_Static_Expression (N);
99 end Analyze_Real_Literal;
100
101 ----------------------------
102 -- Analyze_String_Literal --
103 ----------------------------
104
105 procedure Analyze_String_Literal (N : Node_Id) is
106 begin
107
108 -- The type is eventually inherited from the context. If expansion
109 -- has already established the proper type, do not modify it.
110
111 if No (Etype (N)) then
112 Set_Etype (N, Any_String);
113 end if;
114
115 -- String literals are static in Ada 95. Note that if the subtype
116 -- turns out to be non-static, then the Is_Static_Expression flag
117 -- will be reset in Eval_String_Literal.
118
119 if Ada_95 then
120 Set_Is_Static_Expression (N);
121 end if;
122
123 if Comes_From_Source (N) and then Has_Wide_Character (N) then
124 Check_Restriction (No_Wide_Characters, N);
125 end if;
126 end Analyze_String_Literal;
127
128 end Sem_Ch2;