annotate gcc/ada/sem_ch2.adb @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S E M _ C H 2 --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with Atree; use Atree;
kono
parents:
diff changeset
27 with Namet; use Namet;
kono
parents:
diff changeset
28 with Opt; use Opt;
kono
parents:
diff changeset
29 with Restrict; use Restrict;
kono
parents:
diff changeset
30 with Rident; use Rident;
kono
parents:
diff changeset
31 with Sem_Ch8; use Sem_Ch8;
kono
parents:
diff changeset
32 with Sem_Dim; use Sem_Dim;
kono
parents:
diff changeset
33 with Sinfo; use Sinfo;
kono
parents:
diff changeset
34 with Stand; use Stand;
kono
parents:
diff changeset
35 with Uintp; use Uintp;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 package body Sem_Ch2 is
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 -------------------------------
kono
parents:
diff changeset
40 -- Analyze_Character_Literal --
kono
parents:
diff changeset
41 -------------------------------
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 procedure Analyze_Character_Literal (N : Node_Id) is
kono
parents:
diff changeset
44 begin
kono
parents:
diff changeset
45 -- The type is eventually inherited from the context. If expansion
kono
parents:
diff changeset
46 -- has already established the proper type, do not modify it.
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 if No (Etype (N)) then
kono
parents:
diff changeset
49 Set_Etype (N, Any_Character);
kono
parents:
diff changeset
50 end if;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 Set_Is_Static_Expression (N);
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 if Comes_From_Source (N)
kono
parents:
diff changeset
55 and then not In_Character_Range (UI_To_CC (Char_Literal_Value (N)))
kono
parents:
diff changeset
56 then
kono
parents:
diff changeset
57 Check_Restriction (No_Wide_Characters, N);
kono
parents:
diff changeset
58 end if;
kono
parents:
diff changeset
59 end Analyze_Character_Literal;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 ------------------------
kono
parents:
diff changeset
62 -- Analyze_Identifier --
kono
parents:
diff changeset
63 ------------------------
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure Analyze_Identifier (N : Node_Id) is
kono
parents:
diff changeset
66 begin
kono
parents:
diff changeset
67 -- Ignore call if prior errors, and identifier has no name, since
kono
parents:
diff changeset
68 -- this is the result of some kind of previous error generating a
kono
parents:
diff changeset
69 -- junk identifier.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 if Chars (N) in Error_Name_Or_No_Name
kono
parents:
diff changeset
72 and then Total_Errors_Detected /= 0
kono
parents:
diff changeset
73 then
kono
parents:
diff changeset
74 return;
kono
parents:
diff changeset
75 else
kono
parents:
diff changeset
76 Find_Direct_Name (N);
kono
parents:
diff changeset
77 end if;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 Analyze_Dimension (N);
kono
parents:
diff changeset
80 end Analyze_Identifier;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 -----------------------------
kono
parents:
diff changeset
83 -- Analyze_Integer_Literal --
kono
parents:
diff changeset
84 -----------------------------
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Analyze_Integer_Literal (N : Node_Id) is
kono
parents:
diff changeset
87 begin
kono
parents:
diff changeset
88 Set_Etype (N, Universal_Integer);
kono
parents:
diff changeset
89 Set_Is_Static_Expression (N);
kono
parents:
diff changeset
90 end Analyze_Integer_Literal;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 --------------------------
kono
parents:
diff changeset
93 -- Analyze_Real_Literal --
kono
parents:
diff changeset
94 --------------------------
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 procedure Analyze_Real_Literal (N : Node_Id) is
kono
parents:
diff changeset
97 begin
kono
parents:
diff changeset
98 Set_Etype (N, Universal_Real);
kono
parents:
diff changeset
99 Set_Is_Static_Expression (N);
kono
parents:
diff changeset
100 end Analyze_Real_Literal;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 ----------------------------
kono
parents:
diff changeset
103 -- Analyze_String_Literal --
kono
parents:
diff changeset
104 ----------------------------
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Analyze_String_Literal (N : Node_Id) is
kono
parents:
diff changeset
107 begin
kono
parents:
diff changeset
108 -- The type is eventually inherited from the context. If expansion
kono
parents:
diff changeset
109 -- has already established the proper type, do not modify it.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 if No (Etype (N)) then
kono
parents:
diff changeset
112 Set_Etype (N, Any_String);
kono
parents:
diff changeset
113 end if;
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 -- String literals are static in Ada 95. Note that if the subtype
kono
parents:
diff changeset
116 -- turns out to be non-static, then the Is_Static_Expression flag
kono
parents:
diff changeset
117 -- will be reset in Eval_String_Literal.
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 if Ada_Version >= Ada_95 then
kono
parents:
diff changeset
120 Set_Is_Static_Expression (N);
kono
parents:
diff changeset
121 end if;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 if Comes_From_Source (N) and then Has_Wide_Character (N) then
kono
parents:
diff changeset
124 Check_Restriction (No_Wide_Characters, N);
kono
parents:
diff changeset
125 end if;
kono
parents:
diff changeset
126 end Analyze_String_Literal;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 end Sem_Ch2;