Using C 984 GNU Branch the compiler is producing the following error on more than one program but all with the same issue:
gl120.cbl: 1: Error: syntax error, unexpected Program name
gl120 shows code first few lines and then beginning of Procedure div. :
identification division. *>=============================== *> *>** program-id. gl120. *>**
Now procedure :
77 to-day pic x(10). *> procedure division using ws-calling-data system-record to-day file-defs. *>====================================================================== *> gl120 section. *>************
As you can see it is confusing the first section name with a program name but the Label is the same as the program name, how ever this should not happen.
The fix is just change the name of the section to gl120-Main section
The standard requires that any user-defined word has one type (unless it can be qualified). In this case,
gl120
is both a program-name and a paragraph-name.Do any other implementations accept the above code?
In any case: why does the error message show line 1?
Every compiler I have used since the early 60's including OC v1, 1.1 and v2 have worked with this package. It is only this commit level that has failed.
I think the type of the user-defined word only is necessary for the lookups (only section or paragraph names should be used on
PERFORM
, for example).The real fix here would be to store the user-defined words not only by name but by type also, I think we already have the check for the type in, it seems to be only missing on storing them (where only the name is compared).
Attached is a patch which fixes this bug and provides basic support for program prototypes (the PROGRAM phrase in the REPOSITORY and using prototype-names in CALL and CANCEL statements).
The patch adds two new configuration options:
program-name-redefinition
: if set tono
, redefining the current program's name causes warnings/errors. If set toyes
, there are no warnings/errors, but you can no longer refer to the current program's name in aCALL
orCANCEL
statement (without putting the name in a literal).program-prototypes
.Note that this fix does not extend to functions. Functions are a COBOL 2002 feature, so I think you should strictly follow COBOL 2002 rules in them.
Last edit: Edward Hart 2016-08-03
Bump.
Fix committed in [r1047].
Added a fix in [r1048] to this (the older version lead to SIGSEGV in some compilations within tests/cobol85/IC).
You may want to add a testcase for this issue to tests/testsuite.src.
Last edit: Simon Sobisch 2016-08-09