Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix implicit overlapping move #193

Open
wants to merge 3 commits into
base: gcos4gnucobol-3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -12036,13 +12036,7 @@ cb_build_move_copy (cb_tree src, cb_tree dst)
if (size == 1) {
return CB_BUILD_FUNCALL_2 ("$F", dst, src);
}
if (cb_move_ibm) {
overlapping = 0;
return CB_BUILD_FUNCALL_3 ("cob_move_ibm",
CB_BUILD_CAST_ADDRESS (dst),
CB_BUILD_CAST_ADDRESS (src),
CB_BUILD_CAST_LENGTH (dst));
} else if (overlapping
else if (overlapping
|| CB_FIELD_PTR (src)->storage == CB_STORAGE_LINKAGE
|| CB_FIELD_PTR (dst)->storage == CB_STORAGE_LINKAGE
|| CB_FIELD_PTR (src)->flag_item_based
Expand Down Expand Up @@ -12619,7 +12613,14 @@ cb_build_move_field (cb_tree src, cb_tree dst)
int src_size;
int dst_size;

if (dst_f->flag_any_length || src_f->flag_any_length) {
if (cb_move_ibm) {
overlapping = 0;
return CB_BUILD_FUNCALL_3 ("cob_move_ibm",
CB_BUILD_CAST_ADDRESS (dst),
CB_BUILD_CAST_ADDRESS (src),
CB_BUILD_CAST_LENGTH (dst));
}
else if (dst_f->flag_any_length || src_f->flag_any_length) {
return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
}
src_size = cb_field_size (src);
Expand Down
35 changes: 35 additions & 0 deletions tests/testsuite.src/run_file.at
Original file line number Diff line number Diff line change
Expand Up @@ -14749,3 +14749,38 @@ AT_CHECK([$COMPILE -fdefault-file-colseq=EBCDIC prog.cob])
AT_CHECK([$COBCRUN_DIRECT ./prog])

AT_CLEANUP


AT_SETUP([READ INTO NUMERIC FD RECORD])
AT_KEYWORDS([move overlap])

AT_DATA([testfile], [01234
])
AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MY-FILE ASSIGN TO "testfile"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD MY-FILE.
01 MY-REC PIC 9(5).
PROCEDURE DIVISION.

OPEN INPUT MY-FILE.
READ MY-FILE INTO MY-REC.
DISPLAY MY-REC.
CLOSE MY-FILE.
STOP RUN.
])

AT_CHECK([$COMPILE -fmove-ibm prog.cob -o prog], [0], [], [])

AT_CHECK([./prog], [0], [01234
])

AT_CLEANUP

Loading