From 6376a3c640009ed25a250d677fc7ff0fdd0a2c1c Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 6 Sep 2017 11:47:50 +0200 Subject: [PATCH] [multiple changes] 2017-09-06 Ed Schonberg * sem_attr.adb (Analyze_Attribute, case 'Loop_Entry): Handle properly an attribute reference 'Loop_Entry that appears in the list of indices of an indexed expression, to prevent an infinite loop in the compiler. 2017-09-06 Bob Duff * s-fileio.adb (Name): Do not raise Use_Error for temp files. 2017-09-06 Ed Schonberg * sem_ch4.adb (Analyze_Set_Membership): If an alternative in a set membership is an overloaded enumeration literal, and the type of the alternative is resolved from a previous one, replace the entity of the alternative as well as the type, to prevent inconsistencies between the entity and the type. From-SVN: r251761 --- gcc/ada/ChangeLog | 19 +++++++++++++++++++ gcc/ada/s-fileio.adb | 2 -- gcc/ada/sem_attr.adb | 9 ++++++++- gcc/ada/sem_ch4.adb | 9 +++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 97453305e61..19a6d3aeff6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,22 @@ +2017-09-06 Ed Schonberg + + * sem_attr.adb (Analyze_Attribute, case 'Loop_Entry): Handle + properly an attribute reference 'Loop_Entry that appears in the + list of indices of an indexed expression, to prevent an infinite + loop in the compiler. + +2017-09-06 Bob Duff + + * s-fileio.adb (Name): Do not raise Use_Error for temp files. + +2017-09-06 Ed Schonberg + + * sem_ch4.adb (Analyze_Set_Membership): If an alternative + in a set membership is an overloaded enumeration literal, and + the type of the alternative is resolved from a previous one, + replace the entity of the alternative as well as the type, + to prevent inconsistencies between the entity and the type. + 2017-09-06 Eric Botcazou * ali.ads (ALIs_Record): Add No_Component_Reordering component. diff --git a/gcc/ada/s-fileio.adb b/gcc/ada/s-fileio.adb index 6c449389fd8..c8b44bd1fd8 100644 --- a/gcc/ada/s-fileio.adb +++ b/gcc/ada/s-fileio.adb @@ -742,8 +742,6 @@ package body System.File_IO is begin if File = null then raise Status_Error with "Name: file not open"; - elsif File.Is_Temporary_File then - raise Use_Error with "Name: temporary file has no name"; else return File.Name.all (1 .. File.Name'Length - 1); end if; diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 18107fc2e5e..d7ee88e7bc5 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -4377,7 +4377,14 @@ package body Sem_Attr is -- When the attribute is part of an indexed component, find the first -- expression as it will determine the semantics of 'Loop_Entry. - if Nkind (Context) = N_Indexed_Component then + -- If the attribute is itself an index in an indexed component, i.e. + -- a member of a list, the context itself is not relevant (the code + -- below would lead to an infinite loop) and the attribute applies + -- to the enclosing loop. + + if Nkind (Context) = N_Indexed_Component + and then not Is_List_Member (N) + then E1 := First (Expressions (Context)); E2 := Next (E1); diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 3b0717cf86a..cb50ee77fd8 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -2935,11 +2935,20 @@ package body Sem_Ch4 is -- for all of them. Set_Etype (Alt, It.Typ); + + -- If the alternative is an enumeration literal, use + -- the one for this interpretation. + + if Is_Entity_Name (Alt) then + Set_Entity (Alt, It.Nam); + end if; + Get_Next_Interp (Index, It); if No (It.Typ) then Set_Is_Overloaded (Alt, False); Common_Type := Etype (Alt); + end if; Candidate_Interps := Alt; -- 2.30.2