[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 6 Sep 2011 09:28:33 +0000 (11:28 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 6 Sep 2011 09:28:33 +0000 (11:28 +0200)
2011-09-06  Robert Dewar  <dewar@adacore.com>

* sem_ch8.ads: Minor reformatting

2011-09-06  Thomas Quinot  <quinot@adacore.com>

* s-oscons-tmplt.c, g-socket.adb (GNAT.Sockets.Clear,Set,Is_Set):
Guard against socket values that are not in [0;FD_SETSIZE[

From-SVN: r178576

gcc/ada/ChangeLog
gcc/ada/g-socket.adb
gcc/ada/s-oscons-tmplt.c
gcc/ada/sem_ch8.ads

index 23e4329..b5d3226 100644 (file)
@@ -1,5 +1,14 @@
 2011-09-06  Robert Dewar  <dewar@adacore.com>
 
+       * sem_ch8.ads: Minor reformatting
+
+2011-09-06  Thomas Quinot  <quinot@adacore.com>
+
+       * s-oscons-tmplt.c, g-socket.adb (GNAT.Sockets.Clear,Set,Is_Set):
+       Guard against socket values that are not in [0;FD_SETSIZE[
+
+2011-09-06  Robert Dewar  <dewar@adacore.com>
+
        * s-osinte-linux.ads, a-iteint.ads, exp_ch6.adb, s-solita.adb: Minor
        reformatting.
 
index c562a84..0f02580 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                     Copyright (C) 2001-2010, AdaCore                     --
+--                     Copyright (C) 2001-2011, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -195,6 +195,11 @@ package body GNAT.Sockets is
    procedure Narrow (Item : in out Socket_Set_Type);
    --  Update Last as it may be greater than the real last socket
 
+   procedure Check_For_Fd_Set (Fd : Socket_Type);
+   pragma Inline (Check_For_Fd_Set);
+   --  Raise Constraint_Error if Fd is less than 0 or greater than or equal to
+   --  FD_SETSIZE.
+
    --  Types needed for Datagram_Socket_Stream_Type
 
    type Datagram_Socket_Stream_Type is new Root_Stream_Type with record
@@ -568,6 +573,18 @@ package body GNAT.Sockets is
       Narrow (E_Socket_Set);
    end Check_Selector;
 
+   ----------------------
+   -- Check_For_Fd_Set --
+   ----------------------
+
+   procedure Check_For_Fd_Set (Fd : Socket_Type) is
+   begin
+      if Fd < 0 or else Fd >= SOSC.FD_SETSIZE then
+         raise Constraint_Error with "invalid value for socket set: "
+                                       & Image (Fd);
+      end if;
+   end Check_For_Fd_Set;
+
    -----------
    -- Clear --
    -----------
@@ -578,6 +595,7 @@ package body GNAT.Sockets is
    is
       Last : aliased C.int := C.int (Item.Last);
    begin
+      Check_For_Fd_Set (Socket);
       if Item.Last /= No_Socket then
          Remove_Socket_From_Set (Item.Set'Access, C.int (Socket));
          Last_Socket_In_Set (Item.Set'Access, Last'Unchecked_Access);
@@ -1454,6 +1472,7 @@ package body GNAT.Sockets is
       Socket : Socket_Type) return Boolean
    is
    begin
+      Check_For_Fd_Set (Socket);
       return Item.Last /= No_Socket
         and then Socket <= Item.Last
         and then Is_Socket_In_Set (Item.Set'Access, C.int (Socket)) /= 0;
@@ -2100,6 +2119,7 @@ package body GNAT.Sockets is
 
    procedure Set (Item : in out Socket_Set_Type; Socket : Socket_Type) is
    begin
+      Check_For_Fd_Set (Socket);
       if Item.Last = No_Socket then
 
          --  Uninitialized socket set, make sure it is properly zeroed out
index 4553f47..051cca5 100644 (file)
@@ -1260,6 +1260,7 @@ CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
 
 #define SIZEOF_fd_set (sizeof (fd_set))
 CND(SIZEOF_fd_set, "fd_set");
+CND(FD_SETSIZE, "Max fd value");
 
 #define SIZEOF_struct_hostent (sizeof (struct hostent))
 CND(SIZEOF_struct_hostent, "struct hostent");
index 6d02a41..922b282 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -44,16 +44,16 @@ package Sem_Ch8 is
    -- Subprograms --
    -----------------
 
-   procedure Analyze_Exception_Renaming                 (N : Node_Id);
-   procedure Analyze_Expanded_Name                      (N : Node_Id);
-   procedure Analyze_Generic_Function_Renaming          (N : Node_Id);
-   procedure Analyze_Generic_Package_Renaming           (N : Node_Id);
-   procedure Analyze_Generic_Procedure_Renaming         (N : Node_Id);
-   procedure Analyze_Object_Renaming                    (N : Node_Id);
-   procedure Analyze_Package_Renaming                   (N : Node_Id);
-   procedure Analyze_Subprogram_Renaming                (N : Node_Id);
-   procedure Analyze_Use_Package                        (N : Node_Id);
-   procedure Analyze_Use_Type                           (N : Node_Id);
+   procedure Analyze_Exception_Renaming         (N : Node_Id);
+   procedure Analyze_Expanded_Name              (N : Node_Id);
+   procedure Analyze_Generic_Function_Renaming  (N : Node_Id);
+   procedure Analyze_Generic_Package_Renaming   (N : Node_Id);
+   procedure Analyze_Generic_Procedure_Renaming (N : Node_Id);
+   procedure Analyze_Object_Renaming            (N : Node_Id);
+   procedure Analyze_Package_Renaming           (N : Node_Id);
+   procedure Analyze_Subprogram_Renaming        (N : Node_Id);
+   procedure Analyze_Use_Package                (N : Node_Id);
+   procedure Analyze_Use_Type                   (N : Node_Id);
 
    procedure End_Scope;
    --  Called at end of scope. On exit from blocks and bodies (subprogram,
@@ -71,19 +71,26 @@ package Sem_Ch8 is
 
    procedure End_Use_Package (N : Node_Id);
    procedure End_Use_Type    (N : Node_Id);
-   --  Subsidiaries of End_Use_Clauses.  Also called directly for use clauses
+   --  Subsidiaries of End_Use_Clauses. Also called directly for use clauses
    --  appearing in context clauses.
 
    procedure Find_Direct_Name (N : Node_Id);
    --  Given a direct name (Identifier or Operator_Symbol), this routine scans
-   --  the homonym chain for the name searching for corresponding visible
+   --  the homonym chain for the name, searching for corresponding visible
    --  entities to find the referenced entity (or in the case of overloading,
-   --  entities). On return, the Entity and Etype fields are set. In the
-   --  non-overloaded case, these are the correct final entries. In the
-   --  overloaded case, Is_Overloaded is set, Etype and Entity refer to an
-   --  arbitrary element of the overloads set, and an appropriate list of
-   --  entries has been made in the overload interpretation table (to be
-   --  disambiguated in the resolve phase).
+   --  one candidate interpretation). On return, the Entity and Etype fields
+   --  are set. In the non-overloaded case, these are the correct entries.
+   --  In the overloaded case, the flag Is_Overloaded is set, Etype and Entity
+   --  refer to an arbitrary element of the overloads set, and the appropriate
+   --  entries have been added to the overloads table entry for the node. The
+   --  overloading will be disambiguated during type resolution.
+   --
+   --  Note, when this is called during semantic analysis in the overloaded
+   --  case, the entity set will be the most recently declared homonym. In
+   --  particular, the caller may follow the homonym chain checking for all
+   --  entries in the current scope, and that will give all homonyms that are
+   --  declared before the point of call in the current scope. This is useful
+   --  for example in the processing for pragma Inline.
 
    procedure Find_Selected_Component (N : Node_Id);
    --  Resolve various cases of selected components, recognize expanded names