Commit 151463df by Robert Dewar Committed by Arnaud Charlet

2008-04-08 Robert Dewar <dewar@adacore.com>

	* a-except-2005.ads, a-except-2005.adb, a-except.ads, a-except.adb
	(Raise_Exception): In accordance with AI-446, raise CE for Null_Id
	(Raise_Exception_Always): Fix documentation accordingly

From-SVN: r134018
parent 9392454c
...@@ -420,11 +420,11 @@ package body Ada.Exceptions is ...@@ -420,11 +420,11 @@ package body Ada.Exceptions is
-- Run-Time Check Routines -- -- Run-Time Check Routines --
----------------------------- -----------------------------
-- These routines are called from the runtime to raise a specific -- These routines raise a specific exception with a reason message
-- exception with a reason message attached. The parameters are -- attached. The parameters are the file name and line number in each
-- the file name and line number in each case. The names are keyed -- case. The names are keyed to the codes defined in types.ads and
-- to the codes defined in Types.ads and a-types.h (for example, -- a-types.h (for example, the name Rcheck_05 refers to the Reason
-- the name Rcheck_05 refers to the Reason whose Pos code is 5). -- RT_Exception_Code'Val (5)).
procedure Rcheck_00 (File : System.Address; Line : Integer); procedure Rcheck_00 (File : System.Address; Line : Integer);
procedure Rcheck_01 (File : System.Address; Line : Integer); procedure Rcheck_01 (File : System.Address; Line : Integer);
...@@ -838,20 +838,20 @@ package body Ada.Exceptions is ...@@ -838,20 +838,20 @@ package body Ada.Exceptions is
(E : Exception_Id; (E : Exception_Id;
Message : String := "") Message : String := "")
is is
EF : Exception_Id := E;
begin begin
if E /= null then -- Raise CE if E = Null_ID (AI-446)
Exception_Data.Set_Exception_Msg (E, Message);
Abort_Defer.all; if E = null then
Raise_Current_Excep (E); EF := Constraint_Error'Identity;
end if; end if;
-- Note: if E is null, then we simply return, which is correct Ada 95 -- Go ahead and raise appropriate exception
-- semantics. If we are operating in Ada 2005 mode, then the expander
-- generates a raise Constraint_Error immediately following the call
-- to provide the required Ada 2005 semantics (see AI-329). We do it
-- this way to avoid having run time dependencies on the Ada version.
return; Exception_Data.Set_Exception_Msg (EF, Message);
Abort_Defer.all;
Raise_Current_Excep (EF);
end Raise_Exception; end Raise_Exception;
---------------------------- ----------------------------
......
...@@ -93,12 +93,8 @@ package Ada.Exceptions is ...@@ -93,12 +93,8 @@ package Ada.Exceptions is
pragma Ada_05 (Wide_Wide_Exception_Name); pragma Ada_05 (Wide_Wide_Exception_Name);
procedure Raise_Exception (E : Exception_Id; Message : String := ""); procedure Raise_Exception (E : Exception_Id; Message : String := "");
-- Note: it would be really nice to give a pragma No_Return for this pragma No_Return (Raise_Exception);
-- procedure, but it would be wrong, since Raise_Exception does return -- Note: In accordance with AI-466, CE is raised if E = Null_Id
-- if given the null exception. However we do special case the name in
-- the test in the compiler for issuing a warning for a missing return
-- after this call. Program_Error seems reasonable enough in such a case.
-- See also the routine Raise_Exception_Always in the private part.
function Exception_Message (X : Exception_Occurrence) return String; function Exception_Message (X : Exception_Occurrence) return String;
...@@ -135,11 +131,10 @@ package Ada.Exceptions is ...@@ -135,11 +131,10 @@ package Ada.Exceptions is
(Source : Exception_Occurrence) (Source : Exception_Occurrence)
return Exception_Occurrence_Access; return Exception_Occurrence_Access;
-- Ada 2005 (AI-438): The language revision introduces the -- Ada 2005 (AI-438): The language revision introduces the following
-- following subprograms and attribute definitions. We do not -- subprograms and attribute definitions. We do not provide them
-- provide them explicitly; instead, the corresponding stream -- explicitly. instead, the corresponding stream attributes are made
-- attributes are made available through a pragma Stream_Convert -- available through a pragma Stream_Convert in the private part.
-- in the private part of this package.
-- procedure Read_Exception_Occurrence -- procedure Read_Exception_Occurrence
-- (Stream : not null access Ada.Streams.Root_Stream_Type'Class; -- (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
...@@ -209,10 +204,10 @@ private ...@@ -209,10 +204,10 @@ private
pragma No_Return (Raise_Exception_Always); pragma No_Return (Raise_Exception_Always);
pragma Export (Ada, Raise_Exception_Always, "__gnat_raise_exception"); pragma Export (Ada, Raise_Exception_Always, "__gnat_raise_exception");
-- This differs from Raise_Exception only in that the caller has determined -- This differs from Raise_Exception only in that the caller has determined
-- that for sure the parameter E is not null, and that therefore the call -- that for sure the parameter E is not null, and that therefore no check
-- to this procedure cannot return. The expander converts Raise_Exception -- for Null_Id is required. The expander converts Raise_Exception calls to
-- calls to Raise_Exception_Always if it can determine this is the case. -- Raise_Exception_Always if it can determine this is the case. The Export
-- The Export allows this routine to be accessed from Pure units. -- allows this routine to be accessed from Pure units.
procedure Raise_From_Signal_Handler procedure Raise_From_Signal_Handler
(E : Exception_Id; (E : Exception_Id;
......
...@@ -377,11 +377,11 @@ package body Ada.Exceptions is ...@@ -377,11 +377,11 @@ package body Ada.Exceptions is
-- Run-Time Check Routines -- -- Run-Time Check Routines --
----------------------------- -----------------------------
-- These routines are called from the runtime to raise a specific -- These routines raise a specific exception with a reason message
-- exception with a reason message attached. The parameters are -- attached. The parameters are the file name and line number in each
-- the file name and line number in each case. The names are keyed -- case. The names are keyed to the codes defined in types.ads and
-- to the codes defined in Types.ads and a-types.h (for example, -- a-types.h (for example, the name Rcheck_05 refers to the Reason
-- the name Rcheck_05 refers to the Reason whose Pos code is 5). -- RT_Exception_Code'Val (5)).
procedure Rcheck_00 (File : System.Address; Line : Integer); procedure Rcheck_00 (File : System.Address; Line : Integer);
procedure Rcheck_01 (File : System.Address; Line : Integer); procedure Rcheck_01 (File : System.Address; Line : Integer);
...@@ -807,16 +807,20 @@ package body Ada.Exceptions is ...@@ -807,16 +807,20 @@ package body Ada.Exceptions is
(E : Exception_Id; (E : Exception_Id;
Message : String := "") Message : String := "")
is is
EF : Exception_Id := E;
begin begin
if E /= null then -- Raise CE if E = Null_ID (AI-446)
Exception_Data.Set_Exception_Msg (E, Message);
Abort_Defer.all; if E = null then
Raise_Current_Excep (E); EF := Constraint_Error'Identity;
end if; end if;
-- Note: if E is null then just return (Ada 95 semantics) -- Go ahead and raise appropriate exception
return; Exception_Data.Set_Exception_Msg (EF, Message);
Abort_Defer.all;
Raise_Current_Excep (EF);
end Raise_Exception; end Raise_Exception;
---------------------------- ----------------------------
......
...@@ -84,12 +84,8 @@ package Ada.Exceptions is ...@@ -84,12 +84,8 @@ package Ada.Exceptions is
function Exception_Name (Id : Exception_Id) return String; function Exception_Name (Id : Exception_Id) return String;
procedure Raise_Exception (E : Exception_Id; Message : String := ""); procedure Raise_Exception (E : Exception_Id; Message : String := "");
-- Note: it would be really nice to give a pragma No_Return for this pragma No_Return (Raise_Exception);
-- procedure, but it would be wrong, since Raise_Exception does return if -- Note: In accordance with AI-466, CE is raised if E = Null_Id
-- given the null exception in Ada 95 mode. However we do special case the
-- name in the test in the compiler for issuing a warning for a missing
-- return after this call. Program_Error seems reasonable enough in such a
-- case. See also the routine Raise_Exception_Always in the private part.
function Exception_Message (X : Exception_Occurrence) return String; function Exception_Message (X : Exception_Occurrence) return String;
...@@ -183,10 +179,10 @@ private ...@@ -183,10 +179,10 @@ private
pragma No_Return (Raise_Exception_Always); pragma No_Return (Raise_Exception_Always);
pragma Export (Ada, Raise_Exception_Always, "__gnat_raise_exception"); pragma Export (Ada, Raise_Exception_Always, "__gnat_raise_exception");
-- This differs from Raise_Exception only in that the caller has determined -- This differs from Raise_Exception only in that the caller has determined
-- that for sure the parameter E is not null, and that therefore the call -- that for sure the parameter E is not null, and that therefore no check
-- to this procedure cannot return. The expander converts Raise_Exception -- for Null_Id is required. The expander converts Raise_Exception calls to
-- calls to Raise_Exception_Always if it can determine this is the case. -- Raise_Exception_Always if it can determine this is the case. The Export
-- The Export allows this routine to be accessed from Pure units. -- allows this routine to be accessed from Pure units.
procedure Raise_From_Signal_Handler procedure Raise_From_Signal_Handler
(E : Exception_Id; (E : Exception_Id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment