gm2
[Top][All Lists]
Advanced

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

[Gm2] compile time warning plugin enabled on trunc


From: Gaius Mulley
Subject: [Gm2] compile time warning plugin enabled on trunc
Date: Thu, 19 Apr 2018 14:16:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hi,

the exception detection plugin is installed by default in the gm2
trunc.  If there is interest I'll look at back porting this to 6.4.0.

There are test examples inside:
gcc-versionno/gcc/testsuite/gm2/iso/analysis/fail

the tests are designed to generate compiler warnings (expected fail in
dejagnu terms).

One of these tests is arrayrange.mod which is:

MODULE arrayrange ;  (*!m2iso+gm2*)


VAR
   a: ARRAY [0..3] OF CARDINAL ;


PROCEDURE access (b: ARRAY OF CARDINAL; s: CARDINAL) : CARDINAL ;
BEGIN
   RETURN b[s]
END access ;


BEGIN
   IF access (a, 4) = 4
   THEN
   END
END arrayrange.

and the plugin detects an exception call will occur post optimisation
and issues a warning:

gm2 -g -O2 -fsoft-check-all assignvalue.mod
assignvalue.mod:36:0:inevitable that this error will occur at runtime,
assignment will result in an overflow


and a slightly more aggressive test:


MODULE callassignment4 ;  (*!m2iso+gm2*)

FROM libc IMPORT printf ;


PROCEDURE a (x: INTEGER) : INTEGER ;
BEGIN
   DEC (x) ;
   RETURN x
END a ;


PROCEDURE b (x: INTEGER) : INTEGER ;
BEGIN
   DEC (x) ;
   RETURN x
END b ;


PROCEDURE c (x: INTEGER) : INTEGER ;
BEGIN
   DEC (x) ;
   RETURN x
END c ;


VAR
   y: CARDINAL ;
BEGIN
   printf ("can the plugin detect the range error after these calls?\n");
   printf ("call 1\n");
   printf ("call 2\n");
   printf ("call 3\n");
   printf ("call 4\n");
   y := 1 ;
   IF y = 1
   THEN

   ELSE

   END ;
   y := c(b(a(2)))
END callassignment4.


gm2 -g -O2 -fsoft-check-all callassignment4.mod 
callassignment4.mod:61:0:inevitable that this error will occur at
runtime, assignment will result in an overflow

regards,
Gaius

regards,
Gaius



reply via email to

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