[Bug cobol/126611] New: cobol1: COBOL-WORDS directive broken (and possibly reserved words leaking into preprocessor-reserved words)

simonsobisch at gnu dot org via Gcc-bugs <[email protected]> Mon, 03 Aug 2026 11:09:17 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126611

            Bug ID: 126611
           Summary: cobol1: COBOL-WORDS directive broken (and possibly
                    reserved words leaking into preprocessor-reserved
                    words)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: cobol
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simonsobisch at gnu dot org
  Target Milestone: ---

... not sure if/how this was tested, but from my quick read the following
should work to "rename" the OPTIONS paragraph

       >>COBOL-WORDS SUBSTITUTE "OPTIONS" BY "MY-OPTIONS"

/opt/gnucobol/gcobol/bin/../share/cobol/udf/stored-char-length.cbl:1:33: er=
ror:
syntax error, unexpected invalid token, expecting NAME
    1 |       *>  This function is in public domain.
      |                                 ^~

The issue is that the parser seems to expect a NAME token, where it should
expect a literal.

(side note: the error message points to the wrong file - the --include that=
 is
processed after the one where that error happened, if I --include something
else manually, then the error points to that file)


Using

       >>COBOL-WORDS SUBSTITUTE OPTIONS BY MY-OPTIONS

cobol1 errors with

/opt/gnucobol/gcobol/bin/../share/cobol/udf/stored-char-length.cbl:1:33: er=
ror:
syntax error, unexpected OPTIONS, expecting NAME

(side note: this is definitely wrong, because OPTIONS is not a
preprocessor-reserved word - my guess is that cobol1 may not separate those=
 at
all !?!)


Using=20
       >>COBOL-WORDS UNDEFINE "OPTIONS"

is exactly identical (NAME error, moving the literal to a word errors as ab=
ove)=