gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new warning -Wcase-enum


From: Gaius Mulley
Subject: new warning -Wcase-enum
Date: Wed, 13 Sep 2023 01:29:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hello,

I've added a new warning option on the gcc-13 and master git branches
which detect missing enum case labels in a case statement without an
else clause.  For example:

MODULE missingclause ;  (*!m2iso+gm2*)


TYPE
   colour = (red, green, blue) ;


PROCEDURE init (c: colour) ;
BEGIN
   CASE c OF

   red,
   blue: (* green has been forgotten.  *)

   END
END init ;


VAR
   rgb: colour ;
BEGIN
   init (rgb)
END missingclause.


$ gm2 -Wcase-enum missingclause.mod 
missingclause.mod:10:4: warning: In procedure 'init': not all enumeration 
values in the CASE statements are specified, hint you either need to specify 
each value of 'colour' or use an ELSE clause
   10 |    CASE c OF
      |    ^~~~
missingclause.mod:10:4: warning: the missing enumeration fields are: green

The warnings can be promoted to errors by -Werror.

The option -Wall also enables -Wcase-enum and I see the error message
needs to detect singular occurance :-)

regards,
Gaius




reply via email to

[Prev in Thread] Current Thread [Next in Thread]