diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-24 16:07:09 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-24 16:07:09 +0100 |
commit | c97d7285d9b949ac05ad04f0d76112579c50e240 (patch) | |
tree | 122167c89fc81d8688b17d1d508f3c1a21a863a6 /gcc/ada/layout.adb | |
parent | f3fec19fb8f6ae5c4b95acb6e2b1b76846a84c44 (diff) | |
download | gcc-c97d7285d9b949ac05ad04f0d76112579c50e240.zip gcc-c97d7285d9b949ac05ad04f0d76112579c50e240.tar.gz gcc-c97d7285d9b949ac05ad04f0d76112579c50e240.tar.bz2 |
2014-02-24 Sergey Rybin <rybin@adacore.com frybin>
* gnat_ugn.texi: Misc updates.
2014-02-24 Hristian Kirtchev <kirtchev@adacore.com>
* exp_prag.adb (Expand_Old): Set the type of the generated temporary.
2014-02-24 Gary Dismukes <dismukes@adacore.com>
* layout.adb (Layout_Variant_Record): Instantiate
Generic_Check_Choices and call Check_Choices before calling
Build_Discr_Checking_Funcs, since we need Others_Discrete_Choices
set to prevent generating incorrect discriminant-checking
functions for 'others' variants (functions that unconditionally
return True rather than accounting for the values covered by the
'others' choice).
* sem_eval.ads (Subtypes_Statically_Compatible): Add formal
Formal_Derived_Matching.
(Subtypes_Statically_Match): Add formal Formal_Derived_Matching.
* sem_eval.adb (Subtypes_Statically_Compatible): Pass new
Formal_Derived_Matching formal to Subtypes_Statically_Match.
(Subtypes_Statically_Match): Suppress the Object_Size matching
test in the case where Formal_Derived_Matching is True.
* sem_ch12.adb (Validate_Derived_Type_Instance): Pass
True for Formal_Derived_Matching_Formal on the call to
Subtypes_Statically_Compatible.
From-SVN: r208068
Diffstat (limited to 'gcc/ada/layout.adb')
-rw-r--r-- | gcc/ada/layout.adb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb index ada36de..829d75c 100644 --- a/gcc/ada/layout.adb +++ b/gcc/ada/layout.adb @@ -37,6 +37,7 @@ with Opt; use Opt; with Repinfo; use Repinfo; with Sem; use Sem; with Sem_Aux; use Sem_Aux; +with Sem_Case; use Sem_Case; with Sem_Ch13; use Sem_Ch13; with Sem_Eval; use Sem_Eval; with Sem_Util; use Sem_Util; @@ -2224,9 +2225,54 @@ package body Layout is end if; end Layout_Component_List; + Others_Present : Boolean; + pragma Warnings (Off, Others_Present); + -- Indicates others present, not used in this case + + procedure Non_Static_Choice_Error (Choice : Node_Id); + -- Error routine invoked by the generic instantiation below when + -- the variant part has a nonstatic choice. + + package Variant_Choices_Processing is new + Generic_Check_Choices + (Process_Empty_Choice => No_OP, + Process_Non_Static_Choice => Non_Static_Choice_Error, + Process_Associated_Node => No_OP); + use Variant_Choices_Processing; + + ----------------------------- + -- Non_Static_Choice_Error -- + ----------------------------- + + procedure Non_Static_Choice_Error (Choice : Node_Id) is + begin + Flag_Non_Static_Expr + ("choice given in case expression is not static!", Choice); + end Non_Static_Choice_Error; + -- Start of processing for Layout_Variant_Record begin + -- Call Check_Choices here to ensure that Others_Discrete_Choices + -- gets set on any 'others' choice before the discriminant-checking + -- functions are generated. Otherwise the function for the 'others' + -- alternative will unconditionally return True, causing discriminant + -- checks to fail. However, Check_Choices is now normally delayed + -- until the type's freeze entity is processed, due to requirements + -- coming from subtype predicates, so doing it at this point is + -- probably not right in general, but it's not clear how else to deal + -- with this situation. Perhaps we should only generate declarations + -- for the checking functions here, and somehow delay generation of + -- their bodies, but that would be a nontrivial change. ??? + + declare + VP : constant Node_Id := + Variant_Part (Component_List (Type_Definition (Decl))); + begin + Check_Choices + (VP, Variants (VP), Etype (Name (VP)), Others_Present); + end; + -- We need the discriminant checking functions, since we generate -- calls to these functions for the RM_Size expression, so make -- sure that these functions have been constructed in time. |