This patch adds missing return statements after a call to RAISE. Four
of the modules in libgm2 have procedure functions with missing return
statements. These errors were exposed after the reimplementation of
parameter declaration patch and triggered by -Wreturn-type. The patch
also adds exit statements to the M2RTS noreturn functions.
gcc/m2/ChangeLog:
PR modula2/117555
* gm2-libs-iso/EXCEPTIONS.mod (CurrentNumber): Add return
statement.
* gm2-libs-iso/IOChan.mod (ReadResult): Ditto.
(CurrentFlags): Ditto.
(DeviceError): Ditto.
* gm2-libs-iso/IOLink.mod (DeviceTablePtrValue): Ditto.
* gm2-libs-iso/LongConv.mod (ValueReal): Ditto.
* gm2-libs/M2RTS.mod (Halt): Add noreturn attribute.
Add exit (1).
(HaltC): Add exit (1).
* pge-boot/GM2RTS.cc (M2RTS_Halt): Add exit (1).
(M2RTS_HaltC): Ditto.
(cherry picked from commit
e77fd9aa89c210db6006fcefb03d80bae0fae851)
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
ELSE
RTExceptions.Raise(ORD(M2EXCEPTION.coException),
ADR(__FILE__), __LINE__, __COLUMN__, ADR(__FUNCTION__),
- ADR('current coroutine is not in the exceptional execution state'))
+ ADR('current coroutine is not in the exceptional execution state')) ;
+ RETURN VAL (ExceptionNumber, M2EXCEPTION.exException)
END
END CurrentNumber ;
IF dtp=NIL
THEN
RAISE(iochan, ORD(hardDeviceError),
- 'IOChan.SetReadResult: device table ptr is NIL')
+ 'IOChan.SetReadResult: device table ptr is NIL') ;
+ RETURN IOConsts.notKnown
ELSE
RETURN( dtp^.result )
END
PROCEDURE CurrentFlags (cid: ChanId) : ChanConsts.FlagSet ;
(* Returns the set of flags that currently apply to the channel cid. *)
VAR
- did: IOLink.DeviceId ;
- dtp: IOLink.DeviceTablePtr ;
+ did : IOLink.DeviceId ;
+ dtp : IOLink.DeviceTablePtr ;
+ empty: ChanConsts.FlagSet ;
BEGIN
CheckValid(cid) ;
did := RTio.GetDeviceId(cid) ;
IF dtp=NIL
THEN
RAISE(iochan, ORD(hardDeviceError),
- 'IOChan.SetReadResult: device table ptr is NIL')
+ 'IOChan.SetReadResult: device table ptr is NIL') ;
+ empty := ChanConsts.FlagSet {} ;
+ RETURN empty
ELSE
RETURN( dtp^.flags )
END
IF dtp=NIL
THEN
RAISE(iochan, ORD(hardDeviceError),
- 'IOChan.DeviceError: device table ptr is NIL')
+ 'IOChan.DeviceError: device table ptr is NIL') ;
+ RETURN DeviceError (invalid)
ELSE
RETURN( dtp^.errNum )
END
RETURN( RTio.GetDevicePtr(cid) )
ELSE
EXCEPTIONS.RAISE(iolink, ORD(IOChan.wrongDevice),
- 'IOLink.DeviceTablePtrValue: channel does belong to device')
+ 'IOLink.DeviceTablePtrValue: channel does belong to device') ;
+ RETURN NIL
END
END
END DeviceTablePtrValue ;
RETURN( doValueReal(str) )
ELSE
EXCEPTIONS.RAISE(realConv, ORD(invalid),
- 'LongConv.' + __FUNCTION__ + ': real number is invalid')
+ 'LongConv.' + __FUNCTION__ + ': real number is invalid') ;
+ RETURN 0.0
END
END ValueReal ;
PROCEDURE HaltC (description, filename, function: ADDRESS; line: CARDINAL) ;
BEGIN
- ErrorMessageC (description, filename, line, function)
+ ErrorMessageC (description, filename, line, function) ;
+ exit (1)
END HaltC ;
to stderr and calls exit (1).
*)
-PROCEDURE Halt (description, filename, function: ARRAY OF CHAR; line: CARDINAL) ;
+PROCEDURE Halt (description, filename, function: ARRAY OF CHAR; line: CARDINAL) <* noreturn *> ;
BEGIN
- ErrorMessage (description, filename, line, function)
+ ErrorMessage (description, filename, line, function) ;
+ exit (1)
END Halt ;
memcpy (function, function_, _function_high+1);
M2RTS_ErrorMessage ((const char *) description, _description_high, (const char *) filename, _filename_high, line, (const char *) function, _function_high);
+ libc_exit (1);
}
extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line)
{
ErrorMessageC (description, filename, line, function);
+ libc_exit (1);
}