From: Arnaud Charlet Date: Tue, 25 Apr 2017 09:19:34 +0000 (+0200) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=820f11620e17579c411c3eb31d73a772a2174f85;p=gcc.git [multiple changes] 2017-04-25 Bob Duff * freeze.adb (Freeze_Record_Type): Use the underlying type of the component type to determine whether it's elementary. For representation clause purposes, a private type should behave the same as its full type. * fname.ads, fname.adb (Is_Predefined_File_Name): Make sure things like "system.ali" are recognized as predefined. 2017-04-25 Javier Miranda * debug.adb: Update documentation of -gnatd.6. 2017-04-25 Ed Schonberg * sem_ch5.adb (Preanalyze_Range): Handle properly an Ada2012 element iterator when the name is an overloaded function call, one of whose interpretations yields an array. From-SVN: r247155 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index bd33c416f69..a9de5f0f9e5 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,22 @@ +2017-04-25 Bob Duff + + * freeze.adb (Freeze_Record_Type): Use the + underlying type of the component type to determine whether it's + elementary. For representation clause purposes, a private type + should behave the same as its full type. + * fname.ads, fname.adb (Is_Predefined_File_Name): + Make sure things like "system.ali" are recognized as predefined. + +2017-04-25 Javier Miranda + + * debug.adb: Update documentation of -gnatd.6. + +2017-04-25 Ed Schonberg + + * sem_ch5.adb (Preanalyze_Range): Handle properly an Ada2012 + element iterator when the name is an overloaded function call, + one of whose interpretations yields an array. + 2017-04-25 Bob Duff * uname.ads, uname.adb (Is_Predefined_Unit_Name, diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 5fcb6c8dffb..beddab31321 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -160,7 +160,7 @@ package body Debug is -- d.3 Output debugging information from Exp_Unst -- d.4 Do not delete generated C file in case of errors -- d.5 Do not generate imported subprogram definitions in C code - -- d.6 Do not avoid declaring unreferenced itypes in C code + -- d.6 Do not avoid declaring unreferenced types in C code -- d.7 -- d.8 -- d.9 @@ -781,9 +781,9 @@ package body Debug is -- This debug flag disables this generation when generating C code, -- assuming a proper #include will be used instead. - -- d.6 By default the C back-end avoids declaring itypes that are not + -- d.6 By default the C back-end avoids declaring types that are not -- referenced by the generated C code. This debug flag restores the - -- output of all the itypes. + -- output of all the types. ------------------------------------------ -- Documentation for Binder Debug Flags -- diff --git a/gcc/ada/fname.adb b/gcc/ada/fname.adb index 058489e693f..6db82910641 100644 --- a/gcc/ada/fname.adb +++ b/gcc/ada/fname.adb @@ -134,7 +134,7 @@ package body Fname is return Is_Predefined_File_Name (Fname, Renamings_Included) or else Has_Prefix (Fname, Prefix => "g-") - or else Has_Prefix (Fname, Prefix => "gnat.ad"); + or else Has_Prefix (Fname, Prefix => "gnat."); end Is_Internal_File_Name; function Is_Internal_File_Name @@ -174,9 +174,13 @@ package body Fname is return False; end if; - if Has_Prefix (Fname, Prefix => "ada.ad") -- Ada - or else Has_Prefix (Fname, Prefix => "interfac.ad") -- Interfaces - or else Has_Prefix (Fname, Prefix => "system.ad") -- System + -- We include the "." in the prefixes below, so we don't match (e.g.) + -- adamant.ads. So the first line matches "ada.ads", "ada.adb", and + -- "ada.ali". + + if Has_Prefix (Fname, Prefix => "ada.") -- Ada + or else Has_Prefix (Fname, Prefix => "interfac.") -- Interfaces + or else Has_Prefix (Fname, Prefix => "system.") -- System then return True; end if; @@ -190,45 +194,46 @@ package body Fname is return -- Calendar - Has_Prefix (Fname, Prefix => "calendar.ad") + Has_Prefix (Fname, Prefix => "calendar.") -- Machine_Code - or else Has_Prefix (Fname, Prefix => "machcode.ad") + or else Has_Prefix (Fname, Prefix => "machcode.") -- Unchecked_Conversion - or else Has_Prefix (Fname, Prefix => "unchconv.ad") + or else Has_Prefix (Fname, Prefix => "unchconv.") -- Unchecked_Deallocation - or else Has_Prefix (Fname, Prefix => "unchdeal.ad") + or else Has_Prefix (Fname, Prefix => "unchdeal.") -- Direct_IO - or else Has_Prefix (Fname, Prefix => "directio.ad") + or else Has_Prefix (Fname, Prefix => "directio.") -- IO_Exceptions - or else Has_Prefix (Fname, Prefix => "ioexcept.ad") + or else Has_Prefix (Fname, Prefix => "ioexcept.") -- Sequential_IO - or else Has_Prefix (Fname, Prefix => "sequenio.ad") + or else Has_Prefix (Fname, Prefix => "sequenio.") -- Text_IO - or else Has_Prefix (Fname, Prefix => "text_io.ad"); + or else Has_Prefix (Fname, Prefix => "text_io."); end Is_Predefined_File_Name; function Is_Predefined_File_Name (Fname : File_Name_Type; Renamings_Included : Boolean := True) return Boolean is - begin - return + Result : constant Boolean := Is_Predefined_File_Name (Get_Name_String (Fname), Renamings_Included); + begin + return Result; end Is_Predefined_File_Name; --------------- diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 431fb292139..8451788e8b0 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -3756,14 +3756,15 @@ package body Freeze is -- cannot modify the size of alignment of an aliased component. All_Elem_Components : Boolean := True; - -- Set False if we encounter a component of a composite type + -- True if all components are of a type whose underlying type is + -- elementary. All_Sized_Components : Boolean := True; - -- Set False if we encounter a component with unknown RM_Size + -- True if all components have a known RM_Size All_Storage_Unit_Components : Boolean := True; - -- Set False if we encounter a component of a composite type whose - -- RM_Size is not a multiple of the storage unit. + -- True if all components have an RM_Size that is a multiple of the + -- storage unit. Elem_Component_Total_Esize : Uint := Uint_0; -- Accumulates total Esize values of all elementary components. Used @@ -4091,7 +4092,9 @@ package body Freeze is Sized_Component_Total_RM_Size := Sized_Component_Total_RM_Size + RM_Size (Etype (Comp)); - if Is_Elementary_Type (Etype (Comp)) then + if Present (Underlying_Type (Etype (Comp))) + and then Is_Elementary_Type (Underlying_Type (Etype (Comp))) + then Elem_Component_Total_Esize := Elem_Component_Total_Esize + Esize (Etype (Comp)); else diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 46281ec97c2..fd630afaec7 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3811,6 +3811,7 @@ package body Sem_Ch5 is if Nkind (R_Copy) in N_Subexpr and then Is_Overloaded (R_Copy) then -- Apply preference rules for range of predefined integer types, or + -- check for array or iterable construct for "of" iterator, or -- diagnose true ambiguity. declare @@ -3842,6 +3843,24 @@ package body Sem_Ch5 is exit; end if; end if; + + elsif Nkind (Parent (R_Copy)) = N_Iterator_Specification + and then Of_Present (Parent (R_Copy)) + then + if Is_Array_Type (It.Typ) + or else Has_Aspect (It.Typ, Aspect_Iterator_Element) + or else Has_Aspect (It.Typ, Aspect_Constant_Indexing) + or else Has_Aspect (It.Typ, Aspect_Variable_Indexing) + then + if No (Found) then + Found := It.Typ; + Set_Etype (R_Copy, It.Typ); + + else + Error_Msg_N + ("ambiguous domain of iteration", R_Copy); + end if; + end if; end if; Get_Next_Interp (I, It);