Skip to content

Conversation

@yutaro-sakamoto
Copy link
Contributor

This pull request adds -Wstrict-typing which warns type mismatches strictly.
The following is an example of this option.

prog.cbl

       IDENTIFICATION DIVISION.
       PROGRAM-ID. prog.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 X PIC X(5).
       01 X-EDIT PIC X(3),X(2).
       01 N PIC N(5).
       01 NUM PIC 9(5).
       01 NUM-EDIT PIC 9(3),9(2).
       PROCEDURE DIVISION.
       MAIN SECTION.
         MOVE 12345 TO X.
         MOVE 12345 TO X-EDIT.
         MOVE 12345 TO N.
         MOVE "12345" TO NUM.
         MOVE "12345" TO NUM-EDIT.
> cobj -Wstrict-typing prog.cbl
prog.cbl:12: Warning: Alphanumeric value is expected
prog.cbl:5: Warning: 'X' defined here as PIC X(5)
prog.cbl:13: Warning: Alphanumeric value is expected
prog.cbl:6: Warning: 'X-EDIT' defined here as PIC X(3),X(2)
prog.cbl:14: Warning: National value is expected
prog.cbl:7: Warning: 'N' defined here as PIC N(5)
prog.cbl:15: Warning: Numeric value is expected
prog.cbl:8: Warning: 'NUM' defined here as PIC 9(5)
prog.cbl:16: Warning: Numeric value is expected
prog.cbl:9: Warning: 'NUM-EDIT' defined here as PIC 9(3),9(2)

@yutaro-sakamoto yutaro-sakamoto merged commit 02ddf41 into opensourcecobol:develop Apr 21, 2024
@yutaro-sakamoto yutaro-sakamoto deleted the feat/Wstrict-typing branch April 21, 2024 09:02
This was referenced Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant