https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126002

--- Comment #3 from Peeter Joot <peeterjoot at protonmail dot com> ---
verified fixed on trunk:

ubuntu:/home/peeterjoot/126002> cat paren-sign-condition.cob
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARENSIGN.
      *----------------------------------------------------------------*
      * Minimal reproducer: gcobol rejects a *sign condition*          *
      * (operand IS [NOT] {POSITIVE|NEGATIVE|ZERO}) when it is enclosed *
      * in parentheses, even though the COBOL standard and the IBM      *
      * Enterprise COBOL Language Reference both permit any simple      *
      * condition to be parenthesized.                                  *
      *                                                                 *
      * The three IF statements below are all standard-conforming.      *
      * gcobol accepts #1 and #2 but rejects #3 with:                   *
      *   error: syntax error, unexpected ZERO,                         *
      *          expecting class name or OMITTED                        *
      *----------------------------------------------------------------*
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-N  PIC S9(9) USAGE COMP-5.
       PROCEDURE DIVISION.
      *    #1 sign condition, no parentheses -- ACCEPTED
           IF WS-N IS ZERO
               CONTINUE
           END-IF
      *    #2 relation condition, parenthesized -- ACCEPTED
           IF (WS-N = 0)
               CONTINUE
           END-IF
      *    #3 sign condition, parenthesized -- REJECTED (the bug)
           IF (WS-N IS ZERO)
               CONTINUE
           END-IF
           GOBACK.

ubuntu:/home/peeterjoot/126002> /opt/gcc-trunk-20260717/bin/gcobol
paren-sign-condition.cob -Wl,-rpath,/opt/gcc-trunk-20260717/lib64
ubuntu:/home/peeterjoot/126002> ./a.out

Reply via email to