diff --git a/cobj/codegen.c b/cobj/codegen.c index 2d233a0f..7ea8f3f4 100644 --- a/cobj/codegen.c +++ b/cobj/codegen.c @@ -2667,6 +2667,7 @@ static void joutput_search_all(cb_tree table, cb_tree stmt, cb_tree cond, joutput_prefix(); joutput("int tail = "); if (p->occurs_depending) { + joutput("(int)"); joutput_integer(p->occurs_depending); joutput(" + 1;\n"); } else { diff --git a/cobj/pplex.c b/cobj/pplex.c index 3be62fbb..bffa4e5a 100644 --- a/cobj/pplex.c +++ b/cobj/pplex.c @@ -379,7 +379,7 @@ typedef unsigned int flex_uint32_t; * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START (((yy_start)-1) / 2) +#define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) @@ -2632,8 +2632,8 @@ YY_DECL { default: YY_FATAL_ERROR("fatal flex scanner internal error--no action found"); } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ + } /* end of scanning one token */ + } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer diff --git a/tests/Makefile.am b/tests/Makefile.am index d12e5eb5..d175cf00 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -221,7 +221,8 @@ misc_DEPENDENCIES = \ misc.src/evaluate-switch.at \ misc.src/fserial-variable.at \ misc.src/file-handler-japanese.at \ - misc.src/perform-until-div.at + misc.src/perform-until-div.at \ + misc.src/search-occurs-depending.at EXTRA_DIST = $(srcdir)/package.m4 \ $(TESTS) \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 64a8f7bc..c8d0c140 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -760,7 +760,8 @@ misc_DEPENDENCIES = \ misc.src/evaluate-switch.at \ misc.src/fserial-variable.at \ misc.src/file-handler-japanese.at \ - misc.src/perform-until-div.at + misc.src/perform-until-div.at \ + misc.src/search-occurs-depending.at EXTRA_DIST = $(srcdir)/package.m4 \ $(TESTS) \ diff --git a/tests/misc.at b/tests/misc.at index 449c5271..d3a4da6e 100644 --- a/tests/misc.at +++ b/tests/misc.at @@ -51,3 +51,4 @@ m4_include([evaluate-switch.at]) m4_include([fserial-variable.at]) m4_include([file-handler-japanese.at]) m4_include([perform-until-div.at]) +m4_include([search-occurs-depending.at]) diff --git a/tests/misc.src/search-occurs-depending.at b/tests/misc.src/search-occurs-depending.at new file mode 100644 index 00000000..d14d273d --- /dev/null +++ b/tests/misc.src/search-occurs-depending.at @@ -0,0 +1,32 @@ +AT_SETUP([SEARCH OCCURS DEPENDING]) + +AT_DATA([prog.cbl], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 AAA. + 02 AAA1 PIC X(04) VALUE "HOGE". + 02 FILLER PIC X(18) VALUE SPACE. + 02 AAA2 PIC S9(4) COMP. + 01 BBB. + 02 AAA-1 OCCURS 1 TO 11 DEPENDING ON AAA2 + ASCENDING KEY KEY-A INDEXED BY K1. + 03 KEY-A PIC X(05). + 03 BBB1 PIC X(05). + 03 FILLER PIC X(02). + 01 CCC PIC X(05). + PROCEDURE DIVISION. + SEARCH ALL AAA-1 + AT END + MOVE "ERROR" TO CCC + WHEN KEY-A (K1) = "00001" + MOVE BBB1 (K1) TO CCC + END-SEARCH. + DISPLAY CCC. + STOP RUN. +]) + +AT_CHECK([${COBJ} prog.cbl], [0]) + +AT_CLEANUP