summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/g-socket.adb22
-rw-r--r--gcc/ada/s-oscons-tmplt.c1
-rw-r--r--gcc/ada/sem_ch8.ads45
4 files changed, 57 insertions, 20 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 23e43296ab8..b5d3226fd08 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
index c562a84944c..0f025800163 100644
--- a/gcc/ada/g-socket.adb
+++ b/gcc/ada/g-socket.adb
@@ -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
diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
index 4553f47c512..051cca5456a 100644
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -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");
diff --git a/gcc/ada/sem_ch8.ads b/gcc/ada/sem_ch8.ads
index 6d02a41b76a..922b282cdfa 100644
--- a/gcc/ada/sem_ch8.ads
+++ b/gcc/ada/sem_ch8.ads
@@ -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