diff options
author | Paul Brook <paul@codesourcery.com> | 2006-07-13 18:07:40 +0000 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2006-07-13 18:07:40 +0000 |
commit | a8b20def26f8819020ace682479bdf978f0cd49a (patch) | |
tree | 681df20e561672c8cdda690cdbc48d509157afa3 /gcc/ada | |
parent | 6e53ac993d70b42a4ac831c37ce23ef636c33181 (diff) |
Merge from gcc-4_1-branch revision 114100 (gcc-4_1_1-release)
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/csl/sourcerygxx-4_1@115418 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/ada/sem_res.adb | 72 |
2 files changed, 77 insertions, 8 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f83e607c047..96acf2ecdb1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,16 @@ +2006-05-24 Release Manager + + * GCC 4.1.1 released. + +2006-03-05 Eric Botcazou <ebotcazou@adacore.com> + + Backport from mainline: + 2006-02-13 Ed Schonberg <schonberg@adacore.com> + PR ada/25885 + * sem_res.adb (Set_Literal_String_Subtype): If the lower bound is not + static, wrap the literal in an unchecked conversion, because GCC 4.x + needs a static value for a string bound. + 2006-02-28 Release Manager * GCC 4.1.0 released. diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index f9093455fbb..9c164464ae3 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -6975,29 +6975,85 @@ package body Sem_Res is -------------------------------- procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id) is + Loc : constant Source_Ptr := Sloc (N); + Low_Bound : constant Node_Id := + Type_Low_Bound (Etype (First_Index (Typ))); Subtype_Id : Entity_Id; begin if Nkind (N) /= N_String_Literal then return; - else - Subtype_Id := Create_Itype (E_String_Literal_Subtype, N); end if; + Subtype_Id := Create_Itype (E_String_Literal_Subtype, N); Set_String_Literal_Length (Subtype_Id, UI_From_Int (String_Length (Strval (N)))); - Set_Etype (Subtype_Id, Base_Type (Typ)); - Set_Is_Constrained (Subtype_Id); + Set_Etype (Subtype_Id, Base_Type (Typ)); + Set_Is_Constrained (Subtype_Id); + Set_Etype (N, Subtype_Id); + + if Is_OK_Static_Expression (Low_Bound) then -- The low bound is set from the low bound of the corresponding -- index type. Note that we do not store the high bound in the - -- string literal subtype, but it can be deduced if necssary + -- string literal subtype, but it can be deduced if necessary -- from the length and the low bound. - Set_String_Literal_Low_Bound - (Subtype_Id, Type_Low_Bound (Etype (First_Index (Typ)))); + Set_String_Literal_Low_Bound (Subtype_Id, Low_Bound); + + else + Set_String_Literal_Low_Bound + (Subtype_Id, Make_Integer_Literal (Loc, 1)); + Set_Etype (String_Literal_Low_Bound (Subtype_Id), Standard_Positive); - Set_Etype (N, Subtype_Id); + -- Build bona fide subtypes for the string, and wrap it in an + -- unchecked conversion, because the backend expects the + -- String_Literal_Subtype to have a static lower bound. + + declare + Index_List : constant List_Id := New_List; + Index_Type : constant Entity_Id := Etype (First_Index (Typ)); + High_Bound : constant Node_Id := + Make_Op_Add (Loc, + Left_Opnd => New_Copy_Tree (Low_Bound), + Right_Opnd => + Make_Integer_Literal (Loc, + String_Length (Strval (N)) - 1)); + Array_Subtype : Entity_Id; + Index_Subtype : Entity_Id; + Drange : Node_Id; + Index : Node_Id; + + begin + Index_Subtype := + Create_Itype (Subtype_Kind (Ekind (Index_Type)), N); + Drange := Make_Range (Loc, Low_Bound, High_Bound); + Set_Scalar_Range (Index_Subtype, Drange); + Set_Parent (Drange, N); + Analyze_And_Resolve (Drange, Index_Type); + + Set_Etype (Index_Subtype, Index_Type); + Set_Size_Info (Index_Subtype, Index_Type); + Set_RM_Size (Index_Subtype, RM_Size (Index_Type)); + + Array_Subtype := Create_Itype (E_Array_Subtype, N); + + Index := New_Occurrence_Of (Index_Subtype, Loc); + Set_Etype (Index, Index_Subtype); + Append (Index, Index_List); + + Set_First_Index (Array_Subtype, Index); + Set_Etype (Array_Subtype, Base_Type (Typ)); + Set_Is_Constrained (Array_Subtype, True); + Init_Size_Align (Array_Subtype); + + Rewrite (N, + Make_Unchecked_Type_Conversion (Loc, + Subtype_Mark => New_Occurrence_Of (Array_Subtype, Loc), + Expression => Relocate_Node (N))); + Set_Etype (N, Array_Subtype); + end; + end if; end Set_String_Literal_Subtype; ----------------------------- |