https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119336
Bug ID: 119336
Summary: cobol: missing copybooks break parser
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: cobol
Assignee: unassigned at gcc dot gnu.org
Reporter: simonsobisch at gnu dot org
Target Milestone: ---
The following program compiles and works as expected:
~~~
*> COPY "notthere".
IDENTIFICATION DIVISION.
PROGRAM-ID. 'prog'.
PROCEDURE DIVISION.
00. DISPLAY '1'.
EX. STOP RUN.
~~~
As soon as the COPY statement is uncommented, gcobol raises
test.cob:1:13: error: could not open copybook file for '"notthere"'
1 | COPY "notthere".
| ^
which is fine (the duplicated quotes may be removed from the message and the
full literal be ~~~~~ underlined, but those are only side issues).
The problem: the parser is broken
test.cob:2:23: error: syntax error, unexpected invalid token, expecting
IDENTIFICATION DIVISION or PROGRAM-ID
2 | IDENTIFICATION DIVISION.
| ^
while the rest of the program should be parsed without any problems (not sure
why cobol1 shows an error at the second word, asking for the double-word
token).