gm2
[Top][All Lists]
Advanced

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

ISO FORWARD is now implemented


From: Gaius Mulley
Subject: ISO FORWARD is now implemented
Date: Sat, 19 Oct 2024 14:11:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi,

I've git pushed a patchset which implements the ISO FORWARD keyword to
the development branch of GCC.  The patch also improves parameter and
return type checking.  Parameter mismatch errors should now result in
virtual token being highlighted (or multiple tokens for example the
parameter declaration).

Here are some examples (from the testsuite):

$ cat simpleforward2.mod
MODULE simpleforward2 ;

PROCEDURE foo (c: CARDINAL) ;
BEGIN
END foo ;

PROCEDURE foo ; FORWARD ;

BEGIN
   foo (1)
END simpleforward2.

$ gm2 simpleforward2.mod
simpleforward2.mod:3:11: error: In procedure ‘foo’: the proper declaration for 
‘foo’ has more parameters than the forward declaration
    3 | PROCEDURE foo (c: CARDINAL) ;
      |           ^~~
simpleforward2.mod:7:11: error: the forward declaration for ‘foo’ has less 
parameters than the proper declaration
    7 | PROCEDURE foo ; FORWARD ;
      |           ^~~

$ cat simpleforward3.mod
MODULE simpleforward3 ;

PROCEDURE foo (c: CARDINAL) ;
BEGIN
END foo ;

PROCEDURE foo (c: CARDINAL) : CARDINAL ; FORWARD ;

BEGIN
   foo (1)
END simpleforward3.

$ gm2 simpleforward3.mod
simpleforward3.mod:3:11: error: In procedure ‘foo’: there is no return type for 
‘foo’ specified in the proper declaration whereas a return type is specified in 
the forward declaration
    3 | PROCEDURE foo (c: CARDINAL) ;
      |           ^~~
simpleforward3.mod:7:11: error: there is no return type for ‘foo’ specified in 
the proper declaration whereas a return type is specified in the forward 
declaration
    7 | PROCEDURE foo (c: CARDINAL) : CARDINAL ; FORWARD ;
      |           ^~~

$ cat simpleforward4.mod
MODULE simpleforward4 ;


PROCEDURE foo () : CARDINAL ; FORWARD ;


PROCEDURE foo () ;
BEGIN
   RETURN 0
END foo ;


BEGIN
   IF foo () = 0
   THEN
   END
END simpleforward4.

$ gm2 simpleforward4.mod
simpleforward4.mod:4:11: error: In procedure ‘foo’: there is no return type for 
‘foo’ specified in the proper declaration whereas a return type is specified in 
the forward declaration
    4 | PROCEDURE foo () : CARDINAL ; FORWARD ;
      |           ^~~
simpleforward4.mod:7:11: error: there is no return type for ‘foo’ specified in 
the proper declaration whereas a return type is specified in the forward 
declaration
    7 | PROCEDURE foo () ;
      |           ^~~
$ cat simpleforward5.mod
MODULE simpleforward5 ;

PROCEDURE foo (c: CARDINAL) : CARDINAL ; FORWARD ;
PROCEDURE foo (c: CARDINAL) : CARDINAL ; FORWARD ;

PROCEDURE foo (c: CARDINAL) ;
BEGIN
END foo ;

BEGIN
   foo (1)
END simpleforward5.

$ gm2 simpleforward5.mod
simpleforward5.mod:3:11: error: In procedure ‘foo’: first forward declaration 
of ‘foo’
    3 | PROCEDURE foo (c: CARDINAL) : CARDINAL ; FORWARD ;
      |           ^~~
simpleforward5.mod:4:11: error: forward declaration of procedure ‘foo’ has 
already occurred
    4 | PROCEDURE foo (c: CARDINAL) : CARDINAL ; FORWARD ;
      |           ^~~
$ cat simpleforward7.mod
MODULE simpleforward7 ;

PROCEDURE foo (c: CARDINAL) ; FORWARD ;

PROCEDURE foo (c: INTEGER) ;
BEGIN
END foo ;

BEGIN
   foo (1)
END simpleforward7.

$ gm2 simpleforward7.mod
simpleforward7.mod:3:11: error: In procedure ‘foo’: declaration in the forward 
declaration differs from the proper declaration, 1st parameter is inconsistant, 
the parameter ‘c’ was declared with a different type
    3 | PROCEDURE foo (c: CARDINAL) ; FORWARD ;
      |           ^~~
simpleforward7.mod:5:16: error: declaration in the forward declaration differs 
from the proper declaration, 1st parameter is inconsistant, the parameter ‘c’ 
was declared with a different type
    5 | PROCEDURE foo (c: INTEGER) ;
      |                ^~~~~~~~~~

$ cat simpleforward.mod
MODULE simpleforward ;


PROCEDURE foo ; FORWARD ;

PROCEDURE foo (c: CARDINAL) ;
BEGIN
END foo ;

BEGIN
   foo (1)
END simpleforward.

$ gm2 simpleforward.mod
simpleforward.mod:4:11: error: In procedure ‘foo’: the forward declaration for 
‘foo’ has less parameters than the proper declaration
    4 | PROCEDURE foo ; FORWARD ;
      |           ^~~
simpleforward.mod:6:11: error: the proper declaration for ‘foo’ has more 
parameters than the forward declaration
    6 | PROCEDURE foo (c: CARDINAL) ;
      |           ^~~

$ cat badparam2.mod
IMPLEMENTATION MODULE badparam2 ;

PROCEDURE foo (c: CARDINAL) ;
BEGIN
END foo ;

END badparam2.

$ gm2 badparam2.mod
./badparam2.def:3:11: error: In procedure ‘foo’: declaration of procedure ‘foo’ 
in the definition module differs from the proper declaration, 1st parameter is 
inconsistant, was declared as a VAR parameter
    3 | PROCEDURE foo (VAR c: CARDINAL) ;
      |           ^~~
badparam2.mod:3:16: error: declaration of procedure ‘foo’ in the definition 
module differs from the proper declaration, 1st parameter is inconsistant, ‘c’ 
was not declared as a VAR parameter
    3 | PROCEDURE foo (c: CARDINAL) ;
      |                ^~~~~~~~~~~

$ cat badparam3.mod
IMPLEMENTATION MODULE badparam3 ;

PROCEDURE foo (VAR c: CARDINAL) ;
BEGIN
END foo ;

END badparam3.

$ gm2 badparam3.mod
./badparam3.def:3:11: error: In procedure ‘foo’: declaration of procedure ‘foo’ 
in the definition module differs from the proper declaration, 1st parameter is 
inconsistant, was not declared as a VAR parameter
    3 | PROCEDURE foo (c: CARDINAL) ;
      |           ^~~
badparam3.mod:3:20: error: declaration of procedure ‘foo’ in the definition 
module differs from the proper declaration, 1st parameter is inconsistant, ‘c’ 
was declared as a VAR parameter
    3 | PROCEDURE foo (VAR c: CARDINAL) ;
      |                    ^~~~~~~~~~~

$ cat badparamarray.mod
IMPLEMENTATION MODULE badparamarray ;

PROCEDURE foo (a: CHAR) ;
BEGIN

END foo ;

END badparamarray.

$ gm2 badparamarray.mod
./badparamarray.def:3:11: error: In procedure ‘foo’: declaration of procedure 
‘foo’ in the definition module differs from the proper declaration, 1st 
parameter is inconsistant, the parameter was declared as an ARRAY OF type
    3 | PROCEDURE foo (a: ARRAY OF CHAR) ;
      |           ^~~
./badparamarray.def:3:11: error: declaration in the definition module differs 
from the proper declaration, 1st parameter is inconsistant, the parameter ‘a’ 
was declared with a different type
badparamarray.mod:3:16: error: declaration of procedure ‘foo’ in the definition 
module differs from the proper declaration, 1st parameter is inconsistant, the 
parameter ‘a’ was not declared as an ARRAY OF type
    3 | PROCEDURE foo (a: CHAR) ;
      |                ^~~~~~~
badparamarray.mod:3:16: error: declaration in the definition module differs 
from the proper declaration, 1st parameter is inconsistant, the parameter ‘a’ 
was declared with a different type

$ cat badparam.mod
IMPLEMENTATION MODULE badparam ;

PROCEDURE foo (c: CARDINAL) ;
BEGIN

END foo ;

END badparam.

$ gm2 badparam.mod
./badparam.def:3:11: error: In procedure ‘foo’: declaration in the definition 
module differs from the proper declaration, 1st parameter is inconsistant, the 
parameter ‘c’ was declared with a different type
    3 | PROCEDURE foo (c: CHAR) ;
      |           ^~~
badparam.mod:3:16: error: declaration in the definition module differs from the 
proper declaration, 1st parameter is inconsistant, the parameter ‘c’ was 
declared with a different type
    3 | PROCEDURE foo (c: CARDINAL) ;
      |                ^~~~~~~~~~~

regards,
Gaius



reply via email to

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