diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-06 09:03:57 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-06 09:03:57 +0000 |
commit | 2f582d724268d2f007726a022170c807f61e6b39 (patch) | |
tree | 4a186f295a6dc25425aa5f49e61f8fd57de10f54 /gcc/ada/sem_ch8.adb | |
parent | 38e9ad31b158ba7f719f7eb191ab40d856f1470f (diff) | |
download | gcc-2f582d724268d2f007726a022170c807f61e6b39.tar.gz |
2009-05-06 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Analyze_Object_Renaming): If the object is a function
call returning an unconstrained composite value, create the proper
subtype for it, as is done for object dclarations with unconstrained
nominal subtypes
2009-05-06 Robert Dewar <dewar@adacore.com>
* sem_ch13.adb (Check_Constant_Address_Clause): Minor error message
improvements
* freeze.adb: Minor reformatting
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147156 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch8.adb')
-rw-r--r-- | gcc/ada/sem_ch8.adb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 7b41282288a..9b9f841679d 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -897,6 +897,33 @@ package body Sem_Ch8 is ("\?suggest using an initialized constant object instead", Nam); end if; + + -- If the function call returns an unconstrained type, we + -- must build a constrained subtype for the new entity, in + -- a way similar to what is done for an object declaration + -- with an unconstrained nominal type. + + if Is_Composite_Type (Etype (Nam)) + and then not Is_Constrained (Etype (Nam)) + and then not Has_Unknown_Discriminants (Etype (Nam)) + and then Expander_Active + then + declare + Loc : constant Source_Ptr := Sloc (N); + Subt : constant Entity_Id := + Make_Defining_Identifier (Loc, + Chars => New_Internal_Name ('T')); + begin + Remove_Side_Effects (Nam); + Insert_Action (N, + Make_Subtype_Declaration (Loc, + Defining_Identifier => Subt, + Subtype_Indication => + Make_Subtype_From_Expr (Nam, Etype (Nam)))); + Rewrite (Subtype_Mark (N), New_Occurrence_Of (Subt, Loc)); + Set_Etype (Nam, Subt); + end; + end if; end case; end if; |