#57 RETURNING item must be in LINKAGE SECTION (check missing)

GC 2.2
closed
None
4
2017-05-07
2014-01-02
No

This works:

       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       ENVIRONMENT      DIVISION.
       CONFIGURATION    SECTION.
       REPOSITORY.
           FUNCTION     WITHPAR.
       PROCEDURE        DIVISION.
           DISPLAY WITHPAR(1)
           END-DISPLAY
           STOP RUN.
       END PROGRAM prog.

       IDENTIFICATION   DIVISION.
       FUNCTION-ID.     WITHPAR.
       DATA             DIVISION.
       LINKAGE          SECTION.
       01 PAR-IN        PIC 9.
       01 PAR-OUT       PIC 9.
       PROCEDURE DIVISION USING PAR-IN RETURNING PAR-OUT.
           ADD 1 TO PAR-IN GIVING PAR-OUT END-ADD.
           GOBACK.
       END FUNCTION WITHPAR.

while this

       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       ENVIRONMENT      DIVISION.
       CONFIGURATION    SECTION.
       REPOSITORY.
           FUNCTION     WITHPAR.
       PROCEDURE        DIVISION.
           DISPLAY WITHPAR(1)
           END-DISPLAY
           STOP RUN.
       END PROGRAM prog.

       IDENTIFICATION   DIVISION.
       FUNCTION-ID.     WITHPAR.
       DATA             DIVISION.
       WORKING-STORAGE  SECTION.
       01 PAR-OUT       PIC 9.
       LINKAGE          SECTION.
       01 PAR-IN        PIC 9.
       PROCEDURE DIVISION USING PAR-IN RETURNING PAR-OUT.
           ADD 1 TO PAR-IN GIVING PAR-OUT END-ADD.
           GOBACK.
       END FUNCTION WITHPAR.

leads to

prog.c: In function 'WITHPAR_':
prog.c:315:8: error: incompatible types when assigning to type 'unsigned char[1]' from type 'void *'
   b_10 = cob_malloc (1U);
        ^
prog.c: In function 'WITHOUTPAR_':
prog.c:456:8: error: incompatible types when assigning to type 'unsigned char[1]' from type 'void *'
   b_17 = cob_malloc (1U);
        ^
1 Attachments

Related

Bugs: #58
Discussion: RETURNING items of User-Defined FUNCTIONs - WORKING-STORAGE or LINKAGE items?

Discussion

  • Simon Sobisch

    Simon Sobisch - 2014-01-02

    Possible quick fix (not generating cob_malloc) attached. Likely possible that there's a fix with higher performance.
    With that patch applied both WORKING-STORAGE and LINKAGE items can be used as RETURNING items for UDFs.

    I want to gather some opinions about this issue in general (and the patch) before committing it.

    Simon

     
  • Simon Sobisch

    Simon Sobisch - 2014-01-02
    • assigned_to: Simon Sobisch
     
  • Simon Sobisch

    Simon Sobisch - 2014-11-24
    • Group: unclassified --> GC 2.0
    • Priority: 1 --> 5
     
  • Simon Sobisch

    Simon Sobisch - 2017-04-10
    • summary: UDF: C compiler error if RETURNING items are part of WORKING STORAGE --> RETURNING item must be in LINKAGE SECTION (check missing)- status: open --> accepted
    • Priority: 5 --> 4
     
    Last edit: Simon Sobisch 2017-04-10
  • Simon Sobisch

    Simon Sobisch - 2017-04-10

    After additional checks and as pointed out in the discussion at [08d8b633] RETURNING items must be in LINKAGE SECTION. The MF docs show the same rule.
    Therefore we don't need any change in codegen but in the checks done in the parser.

     

    Related

    Discussion: 08d8b633

  • Edward Hart

    Edward Hart - 2017-04-22

    This bug seems to have been fixed in [r1375].

     

    Related

    Commit: [r1375]

    • Simon Sobisch

      Simon Sobisch - 2017-04-22

      Roger added a check for this in original 2.0 already, I did not found
      out why it wasn't triggered but it is now. I added a bunch of tests in
      the testsuite making sure it will be triggered in the future and found
      another bug.
      I'll close this bug when the testsuite entry is in (next week).

      Simon

       
  • Simon Sobisch

    Simon Sobisch - 2017-05-07
    • status: accepted --> closed
    • Group: 2.2 --> GC 2.2
     
  • Simon Sobisch

    Simon Sobisch - 2017-05-07

    Testcase is in [1585], additional with the missing check "RETURNING item should have not REDEFINES clause" (which I did not found in the standard but is needed as only "real" fields should be passed).

     

Log in to post a comment.