Menu

#268 cobc mis-reading para as a prog name

GC 2.2
closed
None
5 - default
2017-04-10
2016-07-06
No

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

Related

Wish List: #223
Wish List: #260

Discussion

  • Edward Hart

    Edward Hart - 2016-07-15

    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?

     
  • Simon Sobisch

    Simon Sobisch - 2016-07-15

    In any case: why does the error message show line 1?

     
  • Vincent (Bryan) Coen

    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.

     
  • Simon Sobisch

    Simon Sobisch - 2016-07-16
    • status: open --> accepted
    • assigned_to: Edward Hart
     
  • Simon Sobisch

    Simon Sobisch - 2016-07-16

    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).

     
  • Edward Hart

    Edward Hart - 2016-08-03

    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 to no, redefining the current program's name causes warnings/errors. If set to yes, there are no warnings/errors, but you can no longer refer to the current program's name in a CALL or CANCEL 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
    • Edward Hart

      Edward Hart - 2016-08-05

      Bump.

       
  • Edward Hart

    Edward Hart - 2016-08-09
    • status: accepted --> closed
     
  • Edward Hart

    Edward Hart - 2016-08-09

    Fix committed in [r1047].

     
    • Simon Sobisch

      Simon Sobisch - 2016-08-09

      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

Log in to post a comment.