diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2024-11-16 02:32:56 +0000 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2024-11-16 02:32:56 +0000 |
commit | e77fd9aa89c210db6006fcefb03d80bae0fae851 (patch) | |
tree | e2f1a80966542af92ee40c46e503ed46e39c1a2b | |
parent | 63798670e12fb9b2575f67e90d0a0c82b60becba (diff) | |
download | gcc-e77fd9aa89c210db6006fcefb03d80bae0fae851.zip gcc-e77fd9aa89c210db6006fcefb03d80bae0fae851.tar.gz gcc-e77fd9aa89c210db6006fcefb03d80bae0fae851.tar.bz2 |
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.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
-rw-r--r-- | gcc/m2/gm2-libs-iso/EXCEPTIONS.mod | 3 | ||||
-rw-r--r-- | gcc/m2/gm2-libs-iso/IOChan.mod | 15 | ||||
-rw-r--r-- | gcc/m2/gm2-libs-iso/IOLink.mod | 3 | ||||
-rw-r--r-- | gcc/m2/gm2-libs-iso/LongConv.mod | 3 | ||||
-rw-r--r-- | gcc/m2/gm2-libs/M2RTS.mod | 8 | ||||
-rw-r--r-- | 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 21ddd32..6154e8b 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 3361c03..5287a1b 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 8fdc83b..c01698e 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 056fc1e..fb35005 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 5ea4d17..98726a8 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) <* noreturn *> ; 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 b7d9175..bd24902 100644 --- a/gcc/m2/pge-boot/GM2RTS.cc +++ b/gcc/m2/pge-boot/GM2RTS.cc @@ -498,6 +498,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); } @@ -510,6 +511,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); } |