From 1d74252db852527360f1357ed06d573d47122e24 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 18 Nov 2015 11:10:46 +0100 Subject: [PATCH] [multiple changes] 2015-11-18 Thomas Quinot * s-os_lib.ads, s-os_lib.adb(Normalize_Pathname): Support the case of an unresolved Directory argument, by recursively resolving it against the current dir. 2015-11-18 Ed Schonberg * sem_ch6.adb (Process_Formals): A function declaration that returns a class-wide type must have freeing deferred, so that it is not frozen before the class-wide type and its root type are frozen. This is significant when there may be a limited view of the class_wide type in another package. From-SVN: r230526 --- gcc/ada/ChangeLog | 14 ++++++++++++++ gcc/ada/s-os_lib.adb | 41 +++++++++++++++++++++-------------------- gcc/ada/s-os_lib.ads | 22 ++++++++++------------ gcc/ada/sem_ch6.adb | 11 +++++++++++ 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 87dce3b86f0..39e407bada3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2015-11-18 Thomas Quinot + + * s-os_lib.ads, s-os_lib.adb(Normalize_Pathname): Support the case of + an unresolved Directory argument, by recursively resolving it + against the current dir. + +2015-11-18 Ed Schonberg + + * sem_ch6.adb (Process_Formals): A function declaration that + returns a class-wide type must have freeing deferred, so that it + is not frozen before the class-wide type and its root type are + frozen. This is significant when there may be a limited view of + the class_wide type in another package. + 2015-11-18 Hristian Kirtchev * einfo.adb (Has_Non_Null_Refinement): Rename to diff --git a/gcc/ada/s-os_lib.adb b/gcc/ada/s-os_lib.adb index 069a4b3c48b..83c20a9bf46 100644 --- a/gcc/ada/s-os_lib.adb +++ b/gcc/ada/s-os_lib.adb @@ -2081,33 +2081,34 @@ package body System.OS_Lib is ------------------- function Get_Directory (Dir : String) return String is - Result : String (1 .. Dir'Length + 1); - Length : constant Natural := Dir'Length; - begin -- Directory given, add directory separator if needed - if Length > 0 then - Result (1 .. Length) := Dir; + if Dir'Length > 0 then + declare + Result : String := + Normalize_Pathname (Dir, "") & Directory_Separator; + Last : Positive := Result'Last - 1; - -- On Windows, change all '/' to '\' + begin + -- On Windows, change all '/' to '\' + + if On_Windows then + for J in Result'First .. Last - 1 loop + if Result (J) = '/' then + Result (J) := Directory_Separator; + end if; + end loop; + end if; - if On_Windows then - for J in 1 .. Length loop - if Result (J) = '/' then - Result (J) := Directory_Separator; - end if; - end loop; - end if; + -- Include additional directory separator, if needed - -- Add directory separator, if needed + if Result (Last) /= Directory_Separator then + Last := Last + 1; + end if; - if Result (Length) = Directory_Separator then - return Result (1 .. Length); - else - Result (Result'Length) := Directory_Separator; - return Result; - end if; + return Result (Result'First .. Last); + end; -- Directory name not given, get current directory diff --git a/gcc/ada/s-os_lib.ads b/gcc/ada/s-os_lib.ads index 044e38bd5c5..985f492ebef 100644 --- a/gcc/ada/s-os_lib.ads +++ b/gcc/ada/s-os_lib.ads @@ -505,19 +505,17 @@ package System.OS_Lib is Resolve_Links : Boolean := True; Case_Sensitive : Boolean := True) return String; -- Returns a file name as an absolute path name, resolving all relative - -- directories, and symbolic links. The parameter Directory is a fully - -- resolved path name for a directory, or the empty string (the default). - -- Name is the name of a file, which is either relative to the given - -- directory name, if Directory is non-null, or to the current working - -- directory if Directory is null. The result returned is the normalized - -- name of the file. For most cases, if two file names designate the same - -- file through different paths, Normalize_Pathname will return the same - -- canonical name in both cases. However, there are cases when this is not - -- true; for example, this is not true in Unix for two hard links - -- designating the same file. + -- directories, and symbolic links. If Name is a relative path, it is + -- interpreted relative to Directory, or to the current directory if + -- Directory is the empty string (the default). The result returned is + -- the normalized name of the file, containing no "." or ".." components, + -- and no duplicated directory separators. For most cases, if two file + -- names designate the same file through different paths, + -- Normalize_Pathname will return the same canonical name in both cases. + -- However, there are cases when this is not true; for example, this is + -- not true in Unix for two hard links designating the same file. -- - -- On Windows, the returned path will start with a drive letter except - -- when Directory is not empty and does not include a drive letter. If + -- On Windows, the returned path will start with a drive letter. If -- Directory is empty (the default) and Name is a relative path or an -- absolute path without drive letter, the letter of the current drive -- will start the returned path. If Case_Sensitive is True (the default), diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 3eb22f67ee5..a4e15bc49d6 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -10423,6 +10423,17 @@ package body Sem_Ch6 is if Nkind (Related_Nod) = N_Function_Specification then Analyze_Return_Type (Related_Nod); + + -- If return type is class-wide, subprogram freezing may be + -- delayed as well. + + if Is_Class_Wide_Type (Etype (Current_Scope)) + and then not Is_Thunk (Current_Scope) + and then Nkind (Unit_Declaration_Node (Current_Scope)) = + N_Subprogram_Declaration + then + Set_Has_Delayed_Freeze (Current_Scope); + end if; end if; -- Now set the kind (mode) of each formal -- 2.30.2