]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR modula2/117555: Add missing return statement after raise
authorGaius Mulley <gaiusmod2@gmail.com>
Sat, 16 Nov 2024 02:32:56 +0000 (02:32 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Sat, 16 Nov 2024 02:32:56 +0000 (02:32 +0000)
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>
gcc/m2/gm2-libs-iso/EXCEPTIONS.mod
gcc/m2/gm2-libs-iso/IOChan.mod
gcc/m2/gm2-libs-iso/IOLink.mod
gcc/m2/gm2-libs-iso/LongConv.mod
gcc/m2/gm2-libs/M2RTS.mod
gcc/m2/pge-boot/GM2RTS.cc

index 21ddd3267494d781aaff214682149f24545f76f4..6154e8b68fe3f09447502bbcca379d82ccc5ed7a 100644 (file)
@@ -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 ;
 
index 3361c03933918c900b899c36ed0206433e2cf174..5287a1bf9d2131b99b3968047b0ce40bfd3f3a65 100644 (file)
@@ -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
index 8fdc83bad02547fc6dc835a40edc23cd1521f45f..c01698e56ae2ab753bf4be0a2236becf22ddbcd0 100644 (file)
@@ -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 ;
index 056fc1ee1eceb588d8b97ae44e69e901dc9740b1..fb350058c885d92dc0a4f91b19025de307af1b3e 100644 (file)
@@ -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 ;
 
index 5ea4d17c02c2374ea66a4bf6f5e4fece8632bff9..98726a8d737e222f1a9bb65695a80f39e49fb829 100644 (file)
@@ -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 ;
 
 
index b7d917576d29e2d42d679733608ebb68859d5efb..bd249021bb21da804770d6f450db6c17a6b5dccd 100644 (file)
@@ -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);
 }