Skip to content

Commit

Permalink
Merge SVN 4307, 4318
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 13, 2024
1 parent e140b9d commit d54577b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
8 changes: 8 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,14 @@
own storage area and to have the REPORT field offset and report_column
as computed to be exactly where the data should be in the print line

2021-08-28 Simon Sobisch <[email protected]>

* typeck.c (cb_build_assignment_name): fix SELECT filename ASSIGN filename
to lead to "redefinition of filename" when (the default) dialect option
assign-clause=dynamic is active; identical names are now always seen
as literal (similar to assign-clause=external, but without label
handling), see bug 669

2021-07-29 Simon Sobisch <[email protected]>

* parser.y, config.def: changed the auto-setting of the RECURSIVE attribute
Expand Down
15 changes: 10 additions & 5 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,11 @@ cb_build_assignment_name (struct cb_file *cfile, cb_tree name)
if (cfile->assign_type == CB_ASSIGN_EXT_FILE_NAME_REQUIRED) {
return build_external_assignment_name (name);
} else {
const char *name_ptr = CB_NAME (name);
/* handle name as literal if it matches the file name */
if (strcmp (name_ptr, cfile->name) == 0) {
return cb_build_alphanumeric_literal (name_ptr, strlen (name_ptr));
}
current_program->reference_list =
cb_list_add (current_program->reference_list, name);
return name;
Expand Down Expand Up @@ -3959,7 +3964,7 @@ cb_validate_program_data (struct cb_program *prog)

/* Build undeclared assignment names now */
for (l = prog->file_list; l; l = CB_CHAIN (l)) {
validate_assign_name (CB_FILE (CB_VALUE (l)), prog);
validate_assign_name (CB_FILE (CB_VALUE (l)), prog);
}

if (prog->cursor_pos) {
Expand Down Expand Up @@ -4090,7 +4095,7 @@ cb_validate_program_data (struct cb_program *prog)
validate_record_depending (file->record_depending);
}
if (file->organization == COB_ORG_RELATIVE && file->key
&& cb_ref (file->key) != cb_error_node) {
&& cb_ref (file->key) != cb_error_node) {
validate_relative_key_field (file);
}
if (file->file_status) {
Expand Down Expand Up @@ -8586,9 +8591,9 @@ cb_emit_display (cb_tree values, cb_tree upon, cb_tree no_adv,
/* Validate upon and values */
if (values != cb_null) /* DISPLAY OMITTED */ {
if (upon == cb_error_node
|| !values
|| cb_validate_list (values)
|| validate_types_of_display_values (values)) {
|| !values
|| cb_validate_list (values)
|| validate_types_of_display_values (values)) {
return;
}
}
Expand Down
30 changes: 29 additions & 1 deletion tests/testsuite.src/syn_file.at
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (C) 2003-2012, 2014, 2016-2020 Free Software Foundation, Inc.
## Copyright (C) 2003-2012, 2014, 2016-2021 Free Software Foundation, Inc.
## Written by Keisuke Nishida, Roger While, Simon Sobisch, Joe Robbins,
## Edward Hart
##
Expand Down Expand Up @@ -1828,6 +1828,34 @@ prog.cob:12: warning: variable 'fid-file1' will be implicitly defined
AT_CLEANUP


AT_SETUP([ASSIGN external-name matching filename])
AT_KEYWORDS([file external])


AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SYSUT1 ASSIGN TO sysut1.
DATA DIVISION.
FILE SECTION.
FD SYSUT1.
01 SYSUT1-REC PIC X(4).
PROCEDURE DIVISION.
OPEN INPUT SYSUT1.
GOBACK.
])

AT_CHECK([$COMPILE_ONLY -fassign-clause=external prog.cob], [0], [], [])
# ASSIGN dynamic should still work here, it is to be seen as literal
# as long as it matches the file name (note: it still differs as "external"
# would also cut "labels" from the literal
AT_CHECK([$COMPILE_ONLY prog.cob], [0], [], [])
AT_CLEANUP


AT_SETUP([Undeclared ASSIGN variable])
AT_KEYWORDS([file global])

Expand Down
5 changes: 3 additions & 2 deletions tests/testsuite.src/syn_functions.at
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,15 @@ AT_DATA([prog.cob], [
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
DISPLAY FUNCTION ABS (1).
DISPLAY FUNCTION TRIM (" some text here").
DISPLAY FUNCTION STORED-CHAR-LENGTH (" some text here").
DISPLAY FUNCTION SUBSTITUTE ('some text' 'some' 'nice').
STOP RUN.
])

AT_CHECK([$COMPILE_ONLY prog.cob], [0], [], [])
AT_CHECK([$COMPILE_ONLY -std=acu-strict prog.cob], [1], [],
[prog.cob:10: error: FUNCTION 'SUBSTITUTE' unknown
[prog.cob:9: error: FUNCTION 'STORED-CHAR-LENGTH' unknown
prog.cob:10: error: FUNCTION 'SUBSTITUTE' unknown
])

AT_CLEANUP
Expand Down

0 comments on commit d54577b

Please sign in to comment.