Skip to content

Commit

Permalink
Fix context-sensitivity of keyword aliases in configuration
Browse files Browse the repository at this point in the history
cobc/reserved.c (get_user_specified_reserved_word): add check for context sensitivity in aliases

On behalf of Emilien Lemaire <[email protected]>
  • Loading branch information
nberth committed Mar 8, 2023
1 parent ea90d44 commit 57c12c6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2023-03-08 Emilien Lemaire <[email protected]>

* reserved.c (get_user_specified_reserved_word): add check for
context sensitivity in aliases

2023-03-03 Simon Sobisch <[email protected]>

* typeck.c (cb_build_cond_fields): optimize comparison between field and
Expand Down
5 changes: 5 additions & 0 deletions cobc/reserved.c
Original file line number Diff line number Diff line change
Expand Up @@ -4234,6 +4234,11 @@ get_user_specified_reserved_word (struct amendment_list user_reserved)
p = find_default_reserved_word (user_reserved.alias_for, 0);
if (p) {
cobc_reserved.token = p->token;
if (user_reserved.is_context_sensitive) {
cobc_reserved.context_sens =
!!user_reserved.is_context_sensitive;
cobc_reserved.context_test = p->context_test;
}
} else {
/* FIXME: can we point to the fname originally defining the word? */
configuration_error (NULL, 0, 1,
Expand Down
22 changes: 22 additions & 0 deletions tests/testsuite.src/syn_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -8178,3 +8178,25 @@ AT_CHECK([$COMPILE_ONLY -fformat=fixed fixed2.cob], [0], [], [])
AT_CHECK([$COMPILE_ONLY -fformat=fixed domfixed.cob], [0], [], [])

AT_CLEANUP

AT_SETUP([context sensitive alias])
AT_KEYWORDS([misc context alias])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 XX PIC 9.
01 X CONSTANT AS XX OF XX.
PROCEDURE DIVISION.
MOVE X TO XX.
DISPLAY XX NO ADVANCING
END-DISPLAY.
STOP RUN.
])

AT_CHECK([$COMPILE -freserved="XX*=BYTE-LENGTH" prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [1])

AT_CLEANUP

0 comments on commit 57c12c6

Please sign in to comment.