| 1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
| 2 |
|
|
-- --
|
| 3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
| 4 |
|
|
-- --
|
| 5 |
|
|
-- S E M _ C H 2 --
|
| 6 |
|
|
-- --
|
| 7 |
|
|
-- B o d y --
|
| 8 |
|
|
-- --
|
| 9 |
|
|
-- Copyright (C) 1992-2011, 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 Atree; use Atree;
|
| 27 |
|
|
with Errout; use Errout;
|
| 28 |
|
|
with Namet; use Namet;
|
| 29 |
|
|
with Opt; use Opt;
|
| 30 |
|
|
with Restrict; use Restrict;
|
| 31 |
|
|
with Rident; use Rident;
|
| 32 |
|
|
with Sem_Ch8; use Sem_Ch8;
|
| 33 |
|
|
with Sem_Dim; use Sem_Dim;
|
| 34 |
|
|
with Sinfo; use Sinfo;
|
| 35 |
|
|
with Stand; use Stand;
|
| 36 |
|
|
with Uintp; use Uintp;
|
| 37 |
|
|
|
| 38 |
|
|
package body Sem_Ch2 is
|
| 39 |
|
|
|
| 40 |
|
|
-------------------------------
|
| 41 |
|
|
-- Analyze_Character_Literal --
|
| 42 |
|
|
-------------------------------
|
| 43 |
|
|
|
| 44 |
|
|
procedure Analyze_Character_Literal (N : Node_Id) is
|
| 45 |
|
|
begin
|
| 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 (UI_To_CC (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 |
|
|
|
| 80 |
|
|
Analyze_Dimension (N);
|
| 81 |
|
|
end Analyze_Identifier;
|
| 82 |
|
|
|
| 83 |
|
|
-----------------------------
|
| 84 |
|
|
-- Analyze_Integer_Literal --
|
| 85 |
|
|
-----------------------------
|
| 86 |
|
|
|
| 87 |
|
|
procedure Analyze_Integer_Literal (N : Node_Id) is
|
| 88 |
|
|
begin
|
| 89 |
|
|
Set_Etype (N, Universal_Integer);
|
| 90 |
|
|
Set_Is_Static_Expression (N);
|
| 91 |
|
|
end Analyze_Integer_Literal;
|
| 92 |
|
|
|
| 93 |
|
|
--------------------------
|
| 94 |
|
|
-- Analyze_Real_Literal --
|
| 95 |
|
|
--------------------------
|
| 96 |
|
|
|
| 97 |
|
|
procedure Analyze_Real_Literal (N : Node_Id) is
|
| 98 |
|
|
begin
|
| 99 |
|
|
Set_Etype (N, Universal_Real);
|
| 100 |
|
|
Set_Is_Static_Expression (N);
|
| 101 |
|
|
end Analyze_Real_Literal;
|
| 102 |
|
|
|
| 103 |
|
|
----------------------------
|
| 104 |
|
|
-- Analyze_String_Literal --
|
| 105 |
|
|
----------------------------
|
| 106 |
|
|
|
| 107 |
|
|
procedure Analyze_String_Literal (N : Node_Id) is
|
| 108 |
|
|
begin
|
| 109 |
|
|
-- The type is eventually inherited from the context. If expansion
|
| 110 |
|
|
-- has already established the proper type, do not modify it.
|
| 111 |
|
|
|
| 112 |
|
|
if No (Etype (N)) then
|
| 113 |
|
|
Set_Etype (N, Any_String);
|
| 114 |
|
|
end if;
|
| 115 |
|
|
|
| 116 |
|
|
-- String literals are static in Ada 95. Note that if the subtype
|
| 117 |
|
|
-- turns out to be non-static, then the Is_Static_Expression flag
|
| 118 |
|
|
-- will be reset in Eval_String_Literal.
|
| 119 |
|
|
|
| 120 |
|
|
if Ada_Version >= Ada_95 then
|
| 121 |
|
|
Set_Is_Static_Expression (N);
|
| 122 |
|
|
end if;
|
| 123 |
|
|
|
| 124 |
|
|
if Comes_From_Source (N) and then Has_Wide_Character (N) then
|
| 125 |
|
|
Check_Restriction (No_Wide_Characters, N);
|
| 126 |
|
|
end if;
|
| 127 |
|
|
end Analyze_String_Literal;
|
| 128 |
|
|
|
| 129 |
|
|
end Sem_Ch2;
|