From fbc5b447fd8be13f58b3fcea0120cede9eecb399 Mon Sep 17 00:00:00 2001 From: David Declerck Date: Wed, 17 Jul 2024 14:24:04 +0200 Subject: [PATCH] Merge SVN 4758 --- cobc/ChangeLog | 1 + cobc/codegen.c | 6 ++-- tests/testsuite.src/run_misc.at | 57 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 8c485ea91..47279ebcb 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -158,6 +158,7 @@ * cobc.c (cobc_abort_terminate): run into libcob provided abort handling with a default of SIGABRT and a configurable coredump via COBC_CORE_ON_ERROR overriding COB_CORE_ON_ERROR (currently fixed "2") + * codegen.c (output_call) [COB_NON_ALIGNED]: fix CALL RETURNING 2022-10-08 Simon Sobisch diff --git a/cobc/codegen.c b/cobc/codegen.c index b7b578fbc..c3ac34c5c 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -7032,8 +7032,8 @@ output_call (struct cb_call *p) } need_brace = 0; - if (!ret_ptr) { - if (p->call_returning && p->call_returning != cb_null) { + if (p->call_returning && p->call_returning != cb_null) { + if (!ret_ptr) { if (!need_brace) { need_brace = 1; output_block_open (); @@ -7041,7 +7041,7 @@ output_call (struct cb_call *p) output_line ("int ret;"); } #ifdef COB_NON_ALIGNED - else if (dynamic_link) { + else { if (!need_brace) { need_brace = 1; output_block_open (); diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index 4e27cacf4..e48e6193b 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -7369,6 +7369,63 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP +AT_SETUP([CALL RETURNING POINTER]) +AT_KEYWORDS([run_extensions]) + +AT_DATA([prog.cob], [ + identification division. + program-id. prog. + + data division. + working-storage section. + + 01 c-text-pointer usage pointer. + + procedure division. + + call static "cob_getenv" + using "COB_UNIX_LF" + returning c-text-pointer + end-call + + IF function content-of(c-text-pointer) <> "1" + DISPLAY "unexpected value: " + function content-of(c-text-pointer). + + GOBACK. +]) + +AT_DATA([progdyn.cob], [ + identification division. + program-id. progdyn. + + data division. + working-storage section. + + 01 c-text-pointer usage pointer. + + procedure division. + + call "cob_getenv" + using "COB_UNIX_LF" + returning c-text-pointer + end-call + + IF function content-of(c-text-pointer) <> "1" + DISPLAY "unexpected value: " + function content-of(c-text-pointer). + + GOBACK. +]) + +AT_CHECK([$COMPILE -fno-gen-c-decl-static-call prog.cob], [0], [], []) +AT_CHECK([$COMPILE progdyn.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./progdyn], [0], [], []) + +AT_CLEANUP + + AT_SETUP([ON EXCEPTION clause of DISPLAY]) AT_KEYWORDS([runmisc exceptions screen])