GCC with patches for OS216
修订版 | 0640c7d139ea91870c378de96cab14d708517593 (tree) |
---|---|
时间 | 2016-07-07 22:17:51 |
作者 | Arnaud Charlet <charlet@gcc....> |
Commiter | Arnaud Charlet |
[multiple changes]
2016-07-07 Vadim Godunko <godunko@adacore.com>
* adainit.h, adainit.c (gnat_is_read_accessible_file): New
subprogram.
(gnat_is_write_accessible_file): New subprogram.
* s-os_lib.ads, s-os_lib.adb (Is_Read_Accessible_File): New subprogram.
(Is_Write_Accessible_File): New subprogram.
2016-07-07 Justin Squirek <squirek@adacore.com>
* sem_ch12.adb (Install_Body): Minor refactoring in the order
of local functions.
(In_Same_Scope): Change loop condition to be more expressive.
From-SVN: r238116
@@ -1,3 +1,17 @@ | ||
1 | +2016-07-07 Vadim Godunko <godunko@adacore.com> | |
2 | + | |
3 | + * adainit.h, adainit.c (__gnat_is_read_accessible_file): New | |
4 | + subprogram. | |
5 | + (__gnat_is_write_accessible_file): New subprogram. | |
6 | + * s-os_lib.ads, s-os_lib.adb (Is_Read_Accessible_File): New subprogram. | |
7 | + (Is_Write_Accessible_File): New subprogram. | |
8 | + | |
9 | +2016-07-07 Justin Squirek <squirek@adacore.com> | |
10 | + | |
11 | + * sem_ch12.adb (Install_Body): Minor refactoring in the order | |
12 | + of local functions. | |
13 | + (In_Same_Scope): Change loop condition to be more expressive. | |
14 | + | |
1 | 15 | 2016-07-07 Gary Dismukes <dismukes@adacore.com> |
2 | 16 | |
3 | 17 | * sem_ch3.adb, sem_prag.adb, sem_prag.ads, prj-ext.adb, freeze.adb, |
@@ -1912,6 +1912,20 @@ __gnat_is_readable_file_attr (char* name, struct file_attributes* attr) | ||
1912 | 1912 | } |
1913 | 1913 | |
1914 | 1914 | int |
1915 | +__gnat_is_read_accessible_file (char *name) | |
1916 | +{ | |
1917 | +#if defined (_WIN32) | |
1918 | + TCHAR wname [GNAT_MAX_PATH_LEN + 2]; | |
1919 | + | |
1920 | + S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2); | |
1921 | + | |
1922 | + return !_access (wname, 4); | |
1923 | +#else | |
1924 | + return !access (name, R_OK); | |
1925 | +#endif | |
1926 | +} | |
1927 | + | |
1928 | +int | |
1915 | 1929 | __gnat_is_readable_file (char *name) |
1916 | 1930 | { |
1917 | 1931 | struct file_attributes attr; |
@@ -1962,6 +1976,20 @@ __gnat_is_writable_file (char *name) | ||
1962 | 1976 | } |
1963 | 1977 | |
1964 | 1978 | int |
1979 | +__gnat_is_write_accessible_file (char *name) | |
1980 | +{ | |
1981 | +#if defined (_WIN32) | |
1982 | + TCHAR wname [GNAT_MAX_PATH_LEN + 2]; | |
1983 | + | |
1984 | + S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2); | |
1985 | + | |
1986 | + return !_access (wname, 2); | |
1987 | +#else | |
1988 | + return !access (name, W_OK); | |
1989 | +#endif | |
1990 | +} | |
1991 | + | |
1992 | +int | |
1965 | 1993 | __gnat_is_executable_file_attr (char* name, struct file_attributes* attr) |
1966 | 1994 | { |
1967 | 1995 | if (attr->executable == ATTR_UNSET) |
@@ -6,7 +6,7 @@ | ||
6 | 6 | * * |
7 | 7 | * C Header File * |
8 | 8 | * * |
9 | - * Copyright (C) 1992-2015, Free Software Foundation, Inc. * | |
9 | + * Copyright (C) 1992-2016, Free Software Foundation, Inc. * | |
10 | 10 | * * |
11 | 11 | * GNAT is free software; you can redistribute it and/or modify it under * |
12 | 12 | * terms of the GNU General Public License as published by the Free Soft- * |
@@ -207,6 +207,8 @@ extern int __gnat_is_directory (char *); | ||
207 | 207 | extern int __gnat_is_writable_file (char *); |
208 | 208 | extern int __gnat_is_readable_file (char *name); |
209 | 209 | extern int __gnat_is_executable_file (char *name); |
210 | +extern int __gnat_is_write_accessible_file (char *name); | |
211 | +extern int __gnat_is_read_accessible_file (char *name); | |
210 | 212 | |
211 | 213 | extern void __gnat_reset_attributes (struct file_attributes *); |
212 | 214 | extern int __gnat_error_attributes (struct file_attributes *); |
@@ -1495,6 +1495,21 @@ package body System.OS_Lib is | ||
1495 | 1495 | return Is_Directory (F_Name'Address); |
1496 | 1496 | end Is_Directory; |
1497 | 1497 | |
1498 | + ----------------------------- | |
1499 | + -- Is_Read_Accessible_File -- | |
1500 | + ----------------------------- | |
1501 | + | |
1502 | + function Is_Read_Accessible_File (Name : String) return Boolean is | |
1503 | + function Is_Read_Accessible_File (Name : Address) return Integer; | |
1504 | + pragma Import | |
1505 | + (C, Is_Read_Accessible_File, "__gnat_is_read_accessible_file"); | |
1506 | + F_Name : String (1 .. Name'Length + 1); | |
1507 | + begin | |
1508 | + F_Name (1 .. Name'Length) := Name; | |
1509 | + F_Name (F_Name'Last) := ASCII.NUL; | |
1510 | + return Is_Read_Accessible_File (F_Name'Address) /= 0; | |
1511 | + end Is_Read_Accessible_File; | |
1512 | + | |
1498 | 1513 | ---------------------- |
1499 | 1514 | -- Is_Readable_File -- |
1500 | 1515 | ---------------------- |
@@ -1571,6 +1586,21 @@ package body System.OS_Lib is | ||
1571 | 1586 | return Is_Symbolic_Link (F_Name'Address); |
1572 | 1587 | end Is_Symbolic_Link; |
1573 | 1588 | |
1589 | + ------------------------------ | |
1590 | + -- Is_Write_Accessible_File -- | |
1591 | + ------------------------------ | |
1592 | + | |
1593 | + function Is_Write_Accessible_File (Name : String) return Boolean is | |
1594 | + function Is_Write_Accessible_File (Name : Address) return Integer; | |
1595 | + pragma Import | |
1596 | + (C, Is_Write_Accessible_File, "__gnat_is_write_accessible_file"); | |
1597 | + F_Name : String (1 .. Name'Length + 1); | |
1598 | + begin | |
1599 | + F_Name (1 .. Name'Length) := Name; | |
1600 | + F_Name (F_Name'Last) := ASCII.NUL; | |
1601 | + return Is_Write_Accessible_File (F_Name'Address) /= 0; | |
1602 | + end Is_Write_Accessible_File; | |
1603 | + | |
1574 | 1604 | ---------------------- |
1575 | 1605 | -- Is_Writable_File -- |
1576 | 1606 | ---------------------- |
@@ -6,7 +6,7 @@ | ||
6 | 6 | -- -- |
7 | 7 | -- S p e c -- |
8 | 8 | -- -- |
9 | --- Copyright (C) 1995-2015, Free Software Foundation, Inc. -- | |
9 | +-- Copyright (C) 1995-2016, Free Software Foundation, Inc. -- | |
10 | 10 | -- -- |
11 | 11 | -- GNAT is free software; you can redistribute it and/or modify it under -- |
12 | 12 | -- terms of the GNU General Public License as published by the Free Soft- -- |
@@ -457,6 +457,14 @@ package System.OS_Lib is | ||
457 | 457 | -- not actually be writable due to some other process having exclusive |
458 | 458 | -- access. |
459 | 459 | |
460 | + function Is_Read_Accessible_File (Name : String) return Boolean; | |
461 | + -- Determines if the given string, Name, is the name of an existing file | |
462 | + -- that is readable. Returns True if so, False otherwise. | |
463 | + | |
464 | + function Is_Write_Accessible_File (Name : String) return Boolean; | |
465 | + -- Determines if the given string, Name, is the name of an existing file | |
466 | + -- that is writable. Returns True if so, False otherwise. | |
467 | + | |
460 | 468 | function Locate_Exec_On_Path (Exec_Name : String) return String_Access; |
461 | 469 | -- Try to locate an executable whose name is given by Exec_Name in the |
462 | 470 | -- directories listed in the environment Path. If the Exec_Name does not |
@@ -713,7 +713,10 @@ package body Sem_Ch12 is | ||
713 | 713 | -- body. Early instantiations can also appear if generic, instance and |
714 | 714 | -- body are all in the declarative part of a subprogram or entry. Entities |
715 | 715 | -- of packages that are early instantiations are delayed, and their freeze |
716 | - -- node appears after the generic body. | |
716 | + -- node appears after the generic body. This rather complex machinery is | |
717 | + -- needed when nested instantiations are present, because the source does | |
718 | + -- not carry any indication of where the corresponding instance bodies must | |
719 | + -- be installed and frozen. | |
717 | 720 | |
718 | 721 | procedure Install_Formal_Packages (Par : Entity_Id); |
719 | 722 | -- Install the visible part of any formal of the parent that is a formal |
@@ -8927,23 +8930,13 @@ package body Sem_Ch12 is | ||
8927 | 8930 | Gen_Body : Node_Id; |
8928 | 8931 | Gen_Decl : Node_Id) |
8929 | 8932 | is |
8930 | - Act_Id : constant Entity_Id := Corresponding_Spec (Act_Body); | |
8931 | - Act_Unit : constant Node_Id := Unit (Cunit (Get_Source_Unit (N))); | |
8932 | - Gen_Id : constant Entity_Id := Corresponding_Spec (Gen_Body); | |
8933 | - Par : constant Entity_Id := Scope (Gen_Id); | |
8934 | - Gen_Unit : constant Node_Id := | |
8935 | - Unit (Cunit (Get_Source_Unit (Gen_Decl))); | |
8936 | - Orig_Body : Node_Id := Gen_Body; | |
8937 | - F_Node : Node_Id; | |
8938 | - Body_Unit : Node_Id; | |
8939 | - | |
8940 | - Must_Delay : Boolean; | |
8941 | 8933 | |
8942 | - function In_Same_Scope (Generic_Id, Actual_Id : Node_Id) return Boolean; | |
8943 | - -- Check if the generic definition's scope tree and the instantiation's | |
8944 | - -- scope tree share a dependency. | |
8934 | + function In_Same_Scope (Gen_Id, Act_Id : Node_Id) return Boolean; | |
8935 | + -- Check if the generic definition and the instantiation come from | |
8936 | + -- a common scope, in which case the instance must be frozen after | |
8937 | + -- the generic body. | |
8945 | 8938 | |
8946 | - function True_Sloc (N : Node_Id) return Source_Ptr; | |
8939 | + function True_Sloc (N, Act_Unit : Node_Id) return Source_Ptr; | |
8947 | 8940 | -- If the instance is nested inside a generic unit, the Sloc of the |
8948 | 8941 | -- instance indicates the place of the original definition, not the |
8949 | 8942 | -- point of the current enclosing instance. Pending a better usage of |
@@ -8955,20 +8948,22 @@ package body Sem_Ch12 is | ||
8955 | 8948 | -- In_Same_Scope -- |
8956 | 8949 | ------------------- |
8957 | 8950 | |
8958 | - function In_Same_Scope (Generic_Id, Actual_Id : Node_Id) return Boolean | |
8959 | - is | |
8960 | - Act_Scop : Entity_Id := Scope (Actual_Id); | |
8961 | - Gen_Scop : Entity_Id := Scope (Generic_Id); | |
8951 | + function In_Same_Scope (Gen_Id, Act_Id : Node_Id) return Boolean is | |
8952 | + Act_Scop : Entity_Id := Scope (Act_Id); | |
8953 | + Gen_Scop : Entity_Id := Scope (Gen_Id); | |
8954 | + | |
8962 | 8955 | begin |
8963 | - while Scope_Depth_Value (Act_Scop) > 0 | |
8964 | - and then Scope_Depth_Value (Gen_Scop) > 0 | |
8956 | + while Act_Scop /= Standard_Standard | |
8957 | + and then Gen_Scop /= Standard_Standard | |
8965 | 8958 | loop |
8966 | 8959 | if Act_Scop = Gen_Scop then |
8967 | 8960 | return True; |
8968 | 8961 | end if; |
8962 | + | |
8969 | 8963 | Act_Scop := Scope (Act_Scop); |
8970 | 8964 | Gen_Scop := Scope (Gen_Scop); |
8971 | 8965 | end loop; |
8966 | + | |
8972 | 8967 | return False; |
8973 | 8968 | end In_Same_Scope; |
8974 | 8969 |
@@ -8976,7 +8971,7 @@ package body Sem_Ch12 is | ||
8976 | 8971 | -- True_Sloc -- |
8977 | 8972 | --------------- |
8978 | 8973 | |
8979 | - function True_Sloc (N : Node_Id) return Source_Ptr is | |
8974 | + function True_Sloc (N, Act_Unit : Node_Id) return Source_Ptr is | |
8980 | 8975 | Res : Source_Ptr; |
8981 | 8976 | N1 : Node_Id; |
8982 | 8977 |
@@ -8994,6 +8989,18 @@ package body Sem_Ch12 is | ||
8994 | 8989 | return Res; |
8995 | 8990 | end True_Sloc; |
8996 | 8991 | |
8992 | + Act_Id : constant Entity_Id := Corresponding_Spec (Act_Body); | |
8993 | + Act_Unit : constant Node_Id := Unit (Cunit (Get_Source_Unit (N))); | |
8994 | + Gen_Id : constant Entity_Id := Corresponding_Spec (Gen_Body); | |
8995 | + Par : constant Entity_Id := Scope (Gen_Id); | |
8996 | + Gen_Unit : constant Node_Id := | |
8997 | + Unit (Cunit (Get_Source_Unit (Gen_Decl))); | |
8998 | + Orig_Body : Node_Id := Gen_Body; | |
8999 | + F_Node : Node_Id; | |
9000 | + Body_Unit : Node_Id; | |
9001 | + | |
9002 | + Must_Delay : Boolean; | |
9003 | + | |
8997 | 9004 | -- Start of processing for Install_Body |
8998 | 9005 | |
8999 | 9006 | begin |
@@ -9058,7 +9065,8 @@ package body Sem_Ch12 is | ||
9058 | 9065 | and then (Nkind_In (Gen_Unit, N_Package_Declaration, |
9059 | 9066 | N_Generic_Package_Declaration) |
9060 | 9067 | or else (Gen_Unit = Body_Unit |
9061 | - and then True_Sloc (N) < Sloc (Orig_Body))) | |
9068 | + and then True_Sloc (N, Act_Unit) | |
9069 | + < Sloc (Orig_Body))) | |
9062 | 9070 | and then Is_In_Main_Unit (Original_Node (Gen_Unit)) |
9063 | 9071 | and then (In_Same_Scope (Gen_Id, Act_Id))); |
9064 | 9072 |