-- Run-Time Check Routines --
-----------------------------
- -- These routines are called from the runtime to raise a specific
- -- exception with a reason message attached. The parameters are
- -- the file name and line number in each case. The names are keyed
- -- to the codes defined in Types.ads and a-types.h (for example,
- -- the name Rcheck_05 refers to the Reason whose Pos code is 5).
+ -- These routines raise a specific exception with a reason message
+ -- attached. The parameters are the file name and line number in each
+ -- case. The names are keyed to the codes defined in types.ads and
+ -- a-types.h (for example, the name Rcheck_05 refers to the Reason
+ -- RT_Exception_Code'Val (5)).
procedure Rcheck_00 (File : System.Address; Line : Integer);
procedure Rcheck_01 (File : System.Address; Line : Integer);
(E : Exception_Id;
Message : String := "")
is
+ EF : Exception_Id := E;
+
begin
- if E /= null then
- Exception_Data.Set_Exception_Msg (E, Message);
- Abort_Defer.all;
- Raise_Current_Excep (E);
+ -- Raise CE if E = Null_ID (AI-446)
+
+ if E = null then
+ EF := Constraint_Error'Identity;
end if;
- -- Note: if E is null, then we simply return, which is correct Ada 95
- -- 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.
+ -- Go ahead and raise appropriate exception
- return;
+ Exception_Data.Set_Exception_Msg (EF, Message);
+ Abort_Defer.all;
+ Raise_Current_Excep (EF);
end Raise_Exception;
----------------------------
pragma Ada_05 (Wide_Wide_Exception_Name);
procedure Raise_Exception (E : Exception_Id; Message : String := "");
- -- Note: it would be really nice to give a pragma No_Return for this
- -- procedure, but it would be wrong, since Raise_Exception does return
- -- 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.
+ pragma No_Return (Raise_Exception);
+ -- Note: In accordance with AI-466, CE is raised if E = Null_Id
function Exception_Message (X : Exception_Occurrence) return String;
(Source : Exception_Occurrence)
return Exception_Occurrence_Access;
- -- Ada 2005 (AI-438): The language revision introduces the
- -- following subprograms and attribute definitions. We do not
- -- provide them explicitly; instead, the corresponding stream
- -- attributes are made available through a pragma Stream_Convert
- -- in the private part of this package.
+ -- Ada 2005 (AI-438): The language revision introduces the following
+ -- subprograms and attribute definitions. We do not provide them
+ -- explicitly. instead, the corresponding stream attributes are made
+ -- available through a pragma Stream_Convert in the private part.
-- procedure Read_Exception_Occurrence
-- (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
pragma No_Return (Raise_Exception_Always);
pragma Export (Ada, Raise_Exception_Always, "__gnat_raise_exception");
-- 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
- -- to this procedure cannot return. The expander converts Raise_Exception
- -- calls to Raise_Exception_Always if it can determine this is the case.
- -- The Export allows this routine to be accessed from Pure units.
+ -- that for sure the parameter E is not null, and that therefore no check
+ -- for Null_Id is required. The expander converts Raise_Exception calls to
+ -- Raise_Exception_Always if it can determine this is the case. The Export
+ -- allows this routine to be accessed from Pure units.
procedure Raise_From_Signal_Handler
(E : Exception_Id;
-- Run-Time Check Routines --
-----------------------------
- -- These routines are called from the runtime to raise a specific
- -- exception with a reason message attached. The parameters are
- -- the file name and line number in each case. The names are keyed
- -- to the codes defined in Types.ads and a-types.h (for example,
- -- the name Rcheck_05 refers to the Reason whose Pos code is 5).
+ -- These routines raise a specific exception with a reason message
+ -- attached. The parameters are the file name and line number in each
+ -- case. The names are keyed to the codes defined in types.ads and
+ -- a-types.h (for example, the name Rcheck_05 refers to the Reason
+ -- RT_Exception_Code'Val (5)).
procedure Rcheck_00 (File : System.Address; Line : Integer);
procedure Rcheck_01 (File : System.Address; Line : Integer);
(E : Exception_Id;
Message : String := "")
is
+ EF : Exception_Id := E;
+
begin
- if E /= null then
- Exception_Data.Set_Exception_Msg (E, Message);
- Abort_Defer.all;
- Raise_Current_Excep (E);
+ -- Raise CE if E = Null_ID (AI-446)
+
+ if E = null then
+ EF := Constraint_Error'Identity;
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;
----------------------------
function Exception_Name (Id : Exception_Id) return String;
procedure Raise_Exception (E : Exception_Id; Message : String := "");
- -- Note: it would be really nice to give a pragma No_Return for this
- -- procedure, but it would be wrong, since Raise_Exception does return if
- -- 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.
+ pragma No_Return (Raise_Exception);
+ -- Note: In accordance with AI-466, CE is raised if E = Null_Id
function Exception_Message (X : Exception_Occurrence) return String;
pragma No_Return (Raise_Exception_Always);
pragma Export (Ada, Raise_Exception_Always, "__gnat_raise_exception");
-- 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
- -- to this procedure cannot return. The expander converts Raise_Exception
- -- calls to Raise_Exception_Always if it can determine this is the case.
- -- The Export allows this routine to be accessed from Pure units.
+ -- that for sure the parameter E is not null, and that therefore no check
+ -- for Null_Id is required. The expander converts Raise_Exception calls to
+ -- Raise_Exception_Always if it can determine this is the case. The Export
+ -- allows this routine to be accessed from Pure units.
procedure Raise_From_Signal_Handler
(E : Exception_Id;