Skip to content

Commit

Permalink
Modify begin_implicit_statement prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Jul 10, 2023
1 parent 751e2fa commit 071fd28
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
6 changes: 3 additions & 3 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

2023-07-09 Fabrice Le Fessant <[email protected]>

* parser.y: fix code generation for INPUT/CLOSE with double arg
where DECLARATIVES for both arguments were called when only one
failed
* parser.y: fix code generation for OPEN/CLOSE with multiple
filenames, where DECLARATIVES for all arguments were called when
only one argument failed

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

Expand Down
39 changes: 22 additions & 17 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,23 @@ begin_statement_at_tree_pos (enum cob_statement statement, const unsigned int te
cobc_in_area_a = backup_in_area_a;
}

/* create a new statement with base attributes of current_statement
and set this as new current_statement */
/* create a new statement with base attributes of real_statement, the
location of pos and set this as new current_statement */
static void
begin_implicit_statement (void)
begin_implicit_statement (struct cb_statement* real_statement, cb_tree pos)
{
struct cb_statement *new_statement;
new_statement = cb_build_statement (current_statement->statement);
new_statement = cb_build_statement (real_statement->statement);
new_statement->common = current_statement->common;
new_statement->flag_in_debug = !!in_debugging;
new_statement->flag_implicit = 1;
current_statement->body = cb_list_add (current_statement->body,
if (pos){
cb_tree stmt_tree;
stmt_tree = CB_TREE (new_statement);
stmt_tree->source_file = pos->source_file;
stmt_tree->source_line = pos->source_line;
}
real_statement->body = cb_list_add (real_statement->body,
CB_TREE (new_statement));
current_statement = new_statement;
}
Expand Down Expand Up @@ -12905,14 +12911,14 @@ close_files:
is what would happen if we don't save the current statement
and restore it. */
struct cb_statement * saved_current_statement = current_statement ;
begin_implicit_statement ();
begin_implicit_statement (current_statement, $1);
cb_emit_close ($1, $2);
current_statement = saved_current_statement ;
}
| close_files file_name _close_option
{
struct cb_statement * saved_current_statement = current_statement ;
begin_implicit_statement ();
begin_implicit_statement (current_statement, $2);
cb_emit_close ($2, $3);
current_statement = saved_current_statement ;
}
Expand Down Expand Up @@ -13081,13 +13087,13 @@ delete_file_list:
file_name
{
#if 0 /* CHECKME: likely not needed */
begin_implicit_statement ();
begin_implicit_statement (current_statement, $1);
#endif
cb_emit_delete_file ($1);
}
| delete_file_list file_name
{
begin_implicit_statement ();
begin_implicit_statement (current_statement, $2);
cb_emit_delete_file ($2);
}
;
Expand Down Expand Up @@ -14489,7 +14495,7 @@ generate_body:
qualified_word
{
#if 0 /* CHECKME: likely not needed */
begin_implicit_statement ();
begin_implicit_statement (current_statement, $1);
#endif
if ($1 != cb_error_node) {
cb_emit_generate ($1);
Expand Down Expand Up @@ -14743,15 +14749,15 @@ initiate_body:
report_name
{
#if 0 /* CHECKME: likely not needed */
begin_implicit_statement ();
begin_implicit_statement (current_statement, $1);
#endif
if ($1 != cb_error_node) {
cb_emit_initiate ($1);
}
}
| initiate_body report_name
{
begin_implicit_statement ();
begin_implicit_statement (current_statement, $2);
if ($2 != cb_error_node) {
cb_emit_initiate ($2);
}
Expand Down Expand Up @@ -15345,12 +15351,11 @@ open_file_entry:
x = $1;
}

struct cb_statement * top_statement = current_statement ;
for (l = $5; l; l = CB_CHAIN (l)) {
if (CB_VALID_TREE (CB_VALUE (l))) {
struct cb_statement * saved_current_statement = current_statement ;
begin_implicit_statement ();
begin_implicit_statement (top_statement, CB_VALUE(l));
cb_emit_open (CB_VALUE (l), $2, x);
current_statement = saved_current_statement ;
}
}
}
Expand Down Expand Up @@ -16940,15 +16945,15 @@ terminate_body:
report_name
{
#if 0 /* CHECKME: likely not needed */
begin_implicit_statement ();
begin_implicit_statement (current_statement, $1);
#endif
if ($1 != cb_error_node) {
cb_emit_terminate ($1);
}
}
| terminate_body report_name
{
begin_implicit_statement ();
begin_implicit_statement (current_statement, $2);
if ($2 != cb_error_node) {
cb_emit_terminate ($2);
}
Expand Down

0 comments on commit 071fd28

Please sign in to comment.