aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch3.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-10-10 14:17:35 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2013-10-10 14:17:35 +0200
commit15918371923d3e31a9f74c46fbe94e7e1e6d76e6 (patch)
treecd80a5317c5228f3994e9670042a976f5b3fa86b /gcc/ada/sem_ch3.adb
parentb184c8f13820b011a119ce9c900b73986f3c5351 (diff)
downloadgcc-15918371923d3e31a9f74c46fbe94e7e1e6d76e6.zip
gcc-15918371923d3e31a9f74c46fbe94e7e1e6d76e6.tar.gz
gcc-15918371923d3e31a9f74c46fbe94e7e1e6d76e6.tar.bz2
[multiple changes]
2013-10-10 Robert Dewar <dewar@adacore.com> * lib-xref-spark_specific.adb, par-ch13.adb, sem_prag.adb, sem_prag.ads, sem_ch12.adb, sem_attr.adb, sem_ch6.adb, sem_ch13.adb, a-sequio.adb, s-atocou-builtin.adb: Minor reformatting. 2013-10-10 Thomas Quinot <quinot@adacore.com> * s-oscons-tmplt.c (NEED_PTHREAD_CONDATTR_SETCLOCK): This constant needs to be output to s-oscons.h, as it is tested by init.c. 2013-10-10 Robert Dewar <dewar@adacore.com> * exp_ch3.adb (Expand_N_Variant_Part): Don't expand choices, too early * exp_ch5.adb (Expand_N_Case_Statement): Use new Has_SP_Choice flag to avoid expanding choices when not necessary. * exp_util.adb: Minor reformatting * freeze.adb (Freeze_Record_Type): Redo expansion of variants * sem_aggr.adb: Minor reformatting * sem_case.ads, sem_case.adb: Major rewrite, separating Analysis and Checking of choices. * sem_ch3.adb (Analyze_Variant_Part): Rewrite to call new Analyze_Choices. * sem_ch4.adb (Analyze_Case_Expression): Call Analyze_Choices and Check_Choices * sem_ch5.adb (Analyze_Case_Statement): Call Analyze_Choices and Check_Choices * sem_util.adb: Minor reformatting * sinfo.ads, sinfo.adb (Has_SP_Choice): New flag. 2013-10-10 Vincent Celier <celier@adacore.com> * mlib-prj.adb (Build_Library): Do not issue link dynamic libraries with an Rpath, if switch -R was used. 2013-10-10 Tristan Gingold <gingold@adacore.com> * s-stalib.ads (Image_Index_Table_8, Image_Index_Table_16, Image_Index_Table_32): Remove as not used. * s-imgint.adb (Image_Integer): Call Set_Image_Integer and remove duplicated code. From-SVN: r203358
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r--gcc/ada/sem_ch3.adb76
1 files changed, 28 insertions, 48 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index d230b11..e900cfa 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -4590,60 +4590,31 @@ package body Sem_Ch3 is
--------------------------
procedure Analyze_Variant_Part (N : Node_Id) is
+ Discr_Name : Node_Id;
+ Discr_Type : Entity_Id;
- procedure Non_Static_Choice_Error (Choice : Node_Id);
- -- Error routine invoked by the generic instantiation below when the
- -- variant part has a non static choice.
-
- procedure Process_Declarations (Variant : Node_Id);
- -- Analyzes all the declarations associated with a Variant. Needed by
- -- the generic instantiation below.
-
- package Variant_Choices_Processing is new
- Generic_Choices_Processing
- (Get_Alternatives => Variants,
- Process_Empty_Choice => No_OP,
- Process_Non_Static_Choice => Non_Static_Choice_Error,
- Process_Associated_Node => Process_Declarations);
- use Variant_Choices_Processing;
- -- Instantiation of the generic choice processing package
+ procedure Process_Variant (A : Node_Id);
+ -- Analyze declarations for a single variant
- -----------------------------
- -- Non_Static_Choice_Error --
- -----------------------------
+ package Analyze_Variant_Choices is
+ new Generic_Analyze_Choices (Process_Variant);
+ use Analyze_Variant_Choices;
- procedure Non_Static_Choice_Error (Choice : Node_Id) is
- begin
- Flag_Non_Static_Expr
- ("choice given in variant part is not static!", Choice);
- end Non_Static_Choice_Error;
-
- --------------------------
- -- Process_Declarations --
- --------------------------
+ ---------------------
+ -- Process_Variant --
+ ---------------------
- procedure Process_Declarations (Variant : Node_Id) is
+ procedure Process_Variant (A : Node_Id) is
+ CL : constant Node_Id := Component_List (A);
begin
- if not Null_Present (Component_List (Variant)) then
- Analyze_Declarations (Component_Items (Component_List (Variant)));
+ if not Null_Present (CL) then
+ Analyze_Declarations (Component_Items (CL));
- if Present (Variant_Part (Component_List (Variant))) then
- Analyze (Variant_Part (Component_List (Variant)));
+ if Present (Variant_Part (CL)) then
+ Analyze (Variant_Part (CL));
end if;
end if;
- end Process_Declarations;
-
- -- Local Variables
-
- Discr_Name : Node_Id;
- Discr_Type : Entity_Id;
-
- Dont_Care : Boolean;
- Others_Present : Boolean := False;
-
- pragma Warnings (Off, Dont_Care);
- pragma Warnings (Off, Others_Present);
- -- We don't care about the assigned values of any of these
+ end Process_Variant;
-- Start of processing for Analyze_Variant_Part
@@ -4672,9 +4643,18 @@ package body Sem_Ch3 is
return;
end if;
- -- Call the instantiated Analyze_Choices which does the rest of the work
+ -- Now analyze the choices, which also analyzes the declarations that
+ -- are associated with each choice.
+
+ Analyze_Choices (Variants (N), Discr_Type);
+
+ -- Note: we used to instantiate and call Check_Choices here to check
+ -- that the choices covered the discriminant, but it's too early to do
+ -- that because of statically predicated subtypes, whose analysis may
+ -- be deferred to their freeze point which may be as late as the freeze
+ -- point of the containing record. So this call is now to be found in
+ -- Freeze_Record_Declaration.
- Analyze_Choices (N, Discr_Type, Dont_Care, Others_Present);
end Analyze_Variant_Part;
----------------------------