[Ada] Remove discriminant checks processing in gigi
authorArnaud Charlet <charlet@adacore.com>
Tue, 17 Nov 2020 08:39:04 +0000 (03:39 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 17 Dec 2020 10:49:22 +0000 (05:49 -0500)
commit84be0369c8d3a6c94f46906d901d2c5426fb9174
tree1250f8a04ad17af94f101ef30149f1459a0869ba
parent4d3a70f2d1fd213ff669bdaf5752615ab871a2c7
[Ada] Remove discriminant checks processing in gigi

gcc/ada/

* sem_ch4.adb (Analyze_Selected_Component): Request a compile
time error replacement in Apply_Compile_Time_Constraint_Error
in case of an invalid field.
* sem_ch3.adb (Create_Constrained_Components): Take advantage of
Gather_Components also in the case of a record extension and
also constrain records in the case of compile time known discriminant
values, as already done in gigi.
* sem_util.ads, sem_util.adb (Gather_Components): New parameter
Allow_Compile_Time to allow compile time known (but non static)
discriminant values, needed by Create_Constrained_Components,
and new parameter Include_Interface_Tag.
(Is_Dependent_Component_Of_Mutable_Object): Use Original_Node to
perform check on the original tree.
(Is_Object_Reference): Likewise.  Only call Original_Node when
relevant via a new function Safe_Prefix.
(Is_Static_Discriminant_Component, In_Check_Node): New.
(Is_Actual_Out_Or_In_Out_Parameter): New.
* exp_ch4.adb (Expand_N_Selected_Component): Remove no longer needed
code preventing evaluating statically discriminants in more cases.
* exp_ch5.adb (Expand_N_Loop_Statement): Simplify expansion of loops
with an N_Raise_xxx_Error node to avoid confusing the code generator.
(Make_Component_List_Assign): Try to find a constrained type to
extract discriminant values from, so that the case statement
built gets an opportunity to be folded by
Expand_N_Case_Statement.
(Expand_Assign_Record): Update comments, code cleanups.
* sem_attr.adb (Analyze_Attribute): Perform most of the analysis
on the original prefix node to deal properly with a prefix rewritten
as a N_Raise_xxx_Error.
* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Handle properly
a discrete subtype definition being rewritten as N_Raise_xxx_Error.
* sem_ch8.adb (Analyze_Object_Renaming): Handle N_Raise_xxx_Error
nodes as part of the expression being renamed.
* sem_eval.ads, sem_eval.adb (Fold, Eval_Selected_Component): New.
(Compile_Time_Known_Value, Expr_Value, Expr_Rep_Value): Evaluate
static discriminant component values.
* sem_res.adb (Resolve_Selected_Component): Call
Eval_Selected_Component.
12 files changed:
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch5.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_eval.adb
gcc/ada/sem_eval.ads
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads