OSDN Git Service

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