https://gcc.gnu.org/g:89761f1f03565468eb3b15259f6ad42af0cfe198
commit r14-11019-g89761f1f03565468eb3b15259f6ad42af0cfe198 Author: Gaius Mulley <gaiusm...@gmail.com> Date: Mon Dec 2 14:34:32 2024 +0000 [PATCH] PR modula2/117555: Add missing return statement after raise 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 <gaiusm...@gmail.com> Diff: --- gcc/m2/gm2-libs-iso/EXCEPTIONS.mod | 3 ++- gcc/m2/gm2-libs-iso/IOChan.mod | 15 ++++++++++----- gcc/m2/gm2-libs-iso/IOLink.mod | 3 ++- gcc/m2/gm2-libs-iso/LongConv.mod | 3 ++- gcc/m2/gm2-libs/M2RTS.mod | 8 +++++--- gcc/m2/pge-boot/GM2RTS.cc | 2 ++ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod b/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod index 21ddd3267494..6154e8b68fe3 100644 --- a/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod +++ b/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod @@ -81,7 +81,8 @@ BEGIN 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 ; diff --git a/gcc/m2/gm2-libs-iso/IOChan.mod b/gcc/m2/gm2-libs-iso/IOChan.mod index 3361c0393391..5287a1bf9d21 100644 --- a/gcc/m2/gm2-libs-iso/IOChan.mod +++ b/gcc/m2/gm2-libs-iso/IOChan.mod @@ -459,7 +459,8 @@ BEGIN 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 @@ -471,8 +472,9 @@ END ReadResult ; 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) ; @@ -480,7 +482,9 @@ BEGIN 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 @@ -537,7 +541,8 @@ BEGIN 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 diff --git a/gcc/m2/gm2-libs-iso/IOLink.mod b/gcc/m2/gm2-libs-iso/IOLink.mod index 8fdc83bad025..c01698e56ae2 100644 --- a/gcc/m2/gm2-libs-iso/IOLink.mod +++ b/gcc/m2/gm2-libs-iso/IOLink.mod @@ -284,7 +284,8 @@ BEGIN 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 ; diff --git a/gcc/m2/gm2-libs-iso/LongConv.mod b/gcc/m2/gm2-libs-iso/LongConv.mod index 056fc1ee1ece..fb350058c885 100644 --- a/gcc/m2/gm2-libs-iso/LongConv.mod +++ b/gcc/m2/gm2-libs-iso/LongConv.mod @@ -257,7 +257,8 @@ BEGIN 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 ; diff --git a/gcc/m2/gm2-libs/M2RTS.mod b/gcc/m2/gm2-libs/M2RTS.mod index 41add830766e..cb3c26f7ce11 100644 --- a/gcc/m2/gm2-libs/M2RTS.mod +++ b/gcc/m2/gm2-libs/M2RTS.mod @@ -288,7 +288,8 @@ END ErrorMessageC ; PROCEDURE HaltC (description, filename, function: ADDRESS; line: CARDINAL) ; BEGIN - ErrorMessageC (description, filename, line, function) + ErrorMessageC (description, filename, line, function) ; + exit (1) END HaltC ; @@ -298,9 +299,10 @@ 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 ; diff --git a/gcc/m2/pge-boot/GM2RTS.cc b/gcc/m2/pge-boot/GM2RTS.cc index ef5f7cf5ce1e..e3466088f742 100644 --- a/gcc/m2/pge-boot/GM2RTS.cc +++ b/gcc/m2/pge-boot/GM2RTS.cc @@ -496,6 +496,7 @@ extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_ 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); } @@ -508,6 +509,7 @@ extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_ extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line) { ErrorMessageC (description, filename, line, function); + libc_exit (1); }