Skip to content

Commit

Permalink
Merge SVN 3992
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 11, 2024
1 parent 5e11969 commit d212c67
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 72 deletions.
3 changes: 3 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,9 @@
* cobc.c (process_command_line), flag.def: -g now implies the recently
added flags -fgen-c-line-directives and -fgen-c-labels
* codegen.c: output "cob_nop ();" instead of ";" for not-optimized "no op"
* codegen.c (output_initialize_compound): temporary remove of reference
checks not needed any more
* codegen.c (output_param): removed extra fname

2020-11-27 Ron Norman <rjn@inglenet.com>

Expand Down
139 changes: 67 additions & 72 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,17 +2071,13 @@ static void
output_local_indexes (void)
{
int i;
int found = 0;

output_local ("\n/* Subscripts */\n");
if (i_len_used)
output_local ("\tint\t\ti_len = 0;\n");
output_local ("\tint\t\ti_len = 0;\n"); /* used for ODO handling */
for (i = 0; i < COB_MAX_SUBSCRIPTS; i++) {
if (i_counters[i]) {
if (!found) {
found = 1;
output_local ("\n/* Subscripts */\n");
}
output_local ("\tint\t\ti%d = 0, i%d_max = 0;\n", i, i);
output_local ("int\t\ti%d = 0, i%d_max = 0;\n", i, i);
}
}
}
Expand Down Expand Up @@ -4210,7 +4206,6 @@ output_param (cb_tree x, int id)
struct cb_intrinsic *ip;
struct cb_alphabet_name *abp;
cb_tree l;
char fname[12];
int add_comma = 0;

if (x == NULL) {
Expand Down Expand Up @@ -4496,7 +4491,6 @@ output_param (cb_tree x, int id)
if (stack_id >= num_cob_fields) {
num_cob_fields = stack_id + 1;
}
sprintf (fname, "f%d", stack_id++);
if (inside_check != 0) {
if (inside_stack[inside_check - 1] != 0) {
inside_stack[inside_check - 1] = 0;
Expand All @@ -4505,7 +4499,7 @@ output_param (cb_tree x, int id)
output_prefix ();
}
}
output ("COB_SET_FLD(%s, ", fname);
output ("COB_SET_FLD(f%d, ", stack_id++);
output_size (x);
output (", ");
output_data (x);
Expand Down Expand Up @@ -5252,8 +5246,8 @@ propagate_table (cb_tree x, int bgn_idx)
{
struct cb_field *f = cb_code_field (x);
const unsigned int occ = (unsigned int)f->occurs_max;
cob_uli_t len = (cob_uli_t)f->size;
cob_uli_t maxlen = len * occ;
size_t len = (size_t)f->size;
size_t maxlen = len * occ;
unsigned int j = 1;

if (bgn_idx < 1)
Expand Down Expand Up @@ -5286,6 +5280,8 @@ propagate_table (cb_tree x, int bgn_idx)
j = j * 2;
len = len * 2;
} while ((j * 2) < occ);

/* missing piece after last chunk */
if (j < occ
&& maxlen > len) {
output_prefix ();
Expand Down Expand Up @@ -6093,11 +6089,11 @@ output_initialize_compound (struct cb_initialize *p, cb_tree x)
}
} else {
struct cb_reference *ref = CB_REFERENCE (c);
cb_tree save_check, save_length, r2;
cb_tree save_length, r2;

/* Output initialization for the first record */
output_line ("/* initialize first record for %s */", f->name);
save_length = ref->length;
save_check = ref->check;
/* Output all 'check' first */
for (r2 = ref->check; r2; r2 = CB_CHAIN (r2)) {
output_stmt (CB_VALUE (r2));
Expand Down Expand Up @@ -6127,18 +6123,17 @@ output_initialize_compound (struct cb_initialize *p, cb_tree x)
}
}

/* all exceptions should have been raised above,
so temporarily detach from the reference */
ref->check = NULL;
ref->length = NULL;

for (pf = f; pf && !pf->flag_occurs_values; pf = pf->parent);
if (pf == NULL
|| !pf->flag_occurs_values)
|| !pf->flag_occurs_values) {
output_line ("/* copy initialized record for %s to later occurrences */",
f->name);
propagate_table (c, 1);
}

/* restore previous exception-checks for the reference */
ref->check = save_check;
ref->length = save_length;
}
}
Expand Down Expand Up @@ -10819,25 +10814,25 @@ output_report_define_lines (int top, struct cb_report *r, struct cb_field *f, in
struct cb_field *n, *c, *p;
char fname[128];

if(f == NULL)
return;
if (f == NULL)
return;
n = f->sister;
c = f->children;
if(n
&& n->storage != CB_STORAGE_REPORT)
if (n
&& n->storage != CB_STORAGE_REPORT)
n = NULL;
if(n
&& n->report != r)
if (n
&& n->report != r)
n = NULL;
if(c
&& c->storage != CB_STORAGE_REPORT)
if (c
&& c->storage != CB_STORAGE_REPORT)
c = NULL;
if(n
&& (n->report_flag & COB_REPORT_LINE)) {
if (n
&& (n->report_flag & COB_REPORT_LINE)) {
output_report_define_lines(top, r, n, 0);
}
if(c
&& (c->report_flag & COB_REPORT_LINE)) {
if (c
&& (c->report_flag & COB_REPORT_LINE)) {
if (c->flag_occurs
&& !chk_field_variable_size (c)) {
int x;
Expand All @@ -10851,28 +10846,28 @@ output_report_define_lines (int top, struct cb_report *r, struct cb_field *f, in
} else {
c = NULL;
}
if(!top)
if (!top)
c = NULL;

if(f->report_flag & COB_REPORT_LINE_EMITTED) /* Already emitted? */
if (f->report_flag & COB_REPORT_LINE_EMITTED) /* Already emitted? */
return;
f->report_flag |= COB_REPORT_LINE_EMITTED;

if (f->report_flag & COB_REPORT_PAGE_HEADING) {
strcpy(fname,"PAGE HEADING");
} else if(f->report_flag & COB_REPORT_PAGE_FOOTING) {
} else if (f->report_flag & COB_REPORT_PAGE_FOOTING) {
strcpy(fname,"PAGE HEADING");
} else if(f->report_flag & COB_REPORT_HEADING) {
} else if (f->report_flag & COB_REPORT_HEADING) {
strcpy(fname,"REPORT HEADING");
} else if(f->report_flag & COB_REPORT_FOOTING) {
} else if (f->report_flag & COB_REPORT_FOOTING) {
strcpy(fname,"REPORT FOOTING");
} else if(f->report_flag & COB_REPORT_CONTROL_HEADING) {
} else if (f->report_flag & COB_REPORT_CONTROL_HEADING) {
strcpy(fname,"CONTROL HEADING");
} else if(f->report_flag & COB_REPORT_CONTROL_FOOTING) {
} else if (f->report_flag & COB_REPORT_CONTROL_FOOTING) {
strcpy(fname,"CONTROL FOOTING");
} else if(f->report_flag & COB_REPORT_CONTROL_FOOTING_FINAL) {
} else if (f->report_flag & COB_REPORT_CONTROL_FOOTING_FINAL) {
strcpy(fname,"CONTROL FOOTING FINAL");
} else if(f->report_flag & COB_REPORT_CONTROL_HEADING_FINAL) {
} else if (f->report_flag & COB_REPORT_CONTROL_HEADING_FINAL) {
strcpy(fname,"CONTROL HEADING FINAL");
} else {
sprintf(fname,"Line %d",f->common.source_line);
Expand All @@ -10895,27 +10890,27 @@ output_report_define_lines (int top, struct cb_report *r, struct cb_field *f, in
if (f->report_source_id) {
output_local("SourceId:%d ",f->report_source_id);
}
if((f->report_flag & COB_REPORT_LINE)
&& f->children
&& (f->children->report_flag & COB_REPORT_LINE)) {
if ((f->report_flag & COB_REPORT_LINE)
&& f->children
&& (f->children->report_flag & COB_REPORT_LINE)) {
printf("Warning: Ignoring nested LINE %s %d\n",
(f->report_flag & COB_REPORT_LINE_PLUS)?"PLUS":"",
f->report_line);
f->report_line = 0;
f->report_flag &= ~COB_REPORT_LINE_PLUS;
f->report_flag &= ~COB_REPORT_LINE;
}
if(f->report_flag & COB_REPORT_LINE)
if (f->report_flag & COB_REPORT_LINE)
output_local("LINE %s %d ",
(f->report_flag & COB_REPORT_LINE_PLUS)?"PLUS":"",
f->report_line);
output_local("*/\n");
strcpy (report_field_name, "NULL");
if((f->report_flag & COB_REPORT_LINE)
if ((f->report_flag & COB_REPORT_LINE)
&& f->children != NULL) {
output_report_def_fields (1,f->id,f->children,r);
} else if(f->children == NULL) {
if(f->report_flag & COB_REPORT_LINE) {
} else if (f->children == NULL) {
if (f->report_flag & COB_REPORT_LINE) {
output_report_def_fields (1,f->id,f,r);
}
}
Expand All @@ -10939,20 +10934,20 @@ output_report_define_lines (int top, struct cb_report *r, struct cb_field *f, in
}
}
output_local ("static cob_report_line %s%d\t= {", CB_PREFIX_REPORT_LINE,f->id);
if(n == NULL) {
if (n == NULL) {
output_local("NULL,");
} else if(n->level > 1
&& !(n->report_flag & COB_REPORT_LINE)) {
} else if (n->level > 1
&& !(n->report_flag & COB_REPORT_LINE)) {
output_local("NULL, ");
} else {
output_local("&%s%d,",CB_PREFIX_REPORT_LINE,n->id);
}
if(c == NULL)
if (c == NULL)
output_local("NULL,");
else
output_local("&%s%d,",CB_PREFIX_REPORT_LINE,c->id);
output_local("%s,",report_field_name);
if(f->report_control) {
if (f->report_control) {
output_param (f->report_control, 0);
} else {
output_local("NULL");
Expand Down Expand Up @@ -11025,22 +11020,22 @@ output_report_sum_counters (const int top, struct cb_field *f, struct cb_report
f->report_flag |= COB_REPORT_SUM_EMITTED;

if (f->flag_filler) {
if(f->report_flag & COB_REPORT_PAGE_HEADING) {
if (f->report_flag & COB_REPORT_PAGE_HEADING) {
strcpy(fname,"PAGE HEADING");
} else if(f->report_flag & COB_REPORT_PAGE_FOOTING) {
} else if (f->report_flag & COB_REPORT_PAGE_FOOTING) {
strcpy(fname,"PAGE HEADING");
} else if(f->report_flag & COB_REPORT_CONTROL_HEADING) {
} else if (f->report_flag & COB_REPORT_CONTROL_HEADING) {
strcpy(fname,"CONTROL HEADING");
} else if(f->report_flag & COB_REPORT_CONTROL_FOOTING) {
} else if (f->report_flag & COB_REPORT_CONTROL_FOOTING) {
strcpy(fname,"CONTROL FOOTING");
} else if(f->report_flag & COB_REPORT_CONTROL_FOOTING_FINAL) {
} else if (f->report_flag & COB_REPORT_CONTROL_FOOTING_FINAL) {
strcpy(fname,"CONTROL FOOTING FINAL");
} else if(f->report_flag & COB_REPORT_CONTROL_HEADING_FINAL) {
} else if (f->report_flag & COB_REPORT_CONTROL_HEADING_FINAL) {
strcpy(fname,"CONTROL HEADING FINAL");
} else {
strcpy(fname,"");
}
if(f->report_control) {
if (f->report_control) {
sprintf(&fname[strlen(fname)]," %s",cb_code_field(f->report_control)->name);
}
} else if (memcmp (f->name, "FILLER ",7) == 0) {
Expand All @@ -11061,7 +11056,7 @@ output_report_sum_counters (const int top, struct cb_field *f, struct cb_report
output_local("%s ",cb_name (x));
}
}
if(f->report_flag & COB_REPORT_RESET_FINAL)
if (f->report_flag & COB_REPORT_RESET_FINAL)
output_local(" RESET ON FINAL ");
if (f->report_reset) {
output_local(" RESET ON %s ",cb_code_field(f->report_reset)->name);
Expand Down Expand Up @@ -11116,7 +11111,7 @@ output_report_sum_counters (const int top, struct cb_field *f, struct cb_report
output_local("&%s%d_%d,",
CB_PREFIX_REPORT_CONTROL, r_ctl_id, cb_code_field(p->report_control)->id);
break;
} else if(p->report_flag & COB_REPORT_CONTROL_FOOTING_FINAL) {
} else if (p->report_flag & COB_REPORT_CONTROL_FOOTING_FINAL) {
ctl_foot = 1;
output_local("NULL,");
break;
Expand Down Expand Up @@ -11144,11 +11139,11 @@ output_report_definition (struct cb_report *p, struct cb_report *n)

output_local("\n");
for(i= p->num_lines-1; i >= 0; i--) {
if(p->line_ids[i]->level == 1)
if (p->line_ids[i]->level == 1)
output_report_define_lines(1,p,p->line_ids[i], 0);
}
output_local ("\n");
if(p->controls) {
if (p->controls) {
for (l = p->controls; l; l = CB_CHAIN (l)) {
s = cb_code_field(l);
s->count++;
Expand All @@ -11167,7 +11162,7 @@ output_report_definition (struct cb_report *p, struct cb_report *n)
output_local ("static cob_report %s%s = {0x%X,\t",
CB_PREFIX_REPORT, p->cname, COB_REPORT_VERSION);
output_local ("\"%s\",\n\t\t",p->name);
if(n != NULL) {
if (n != NULL) {
output_local ("&%s%s,", CB_PREFIX_REPORT, n->cname); /* next report */
} else {
output_local ("NULL,");
Expand All @@ -11186,28 +11181,28 @@ output_report_definition (struct cb_report *p, struct cb_report *n)
} else {
output_local("NULL,");
}
if(p->num_lines > 0) {
if (p->num_lines > 0) {
output_local ("&%s%d,",CB_PREFIX_REPORT_LINE,p->line_ids[0]->id);
} else {
output_local("NULL,");
}
if(p->t_heading_final != NULL) {
if (p->t_heading_final != NULL) {
output_local ("&%s%d,",CB_PREFIX_REPORT_LINE,p->t_heading_final->id);
} else {
output_local("NULL,");
}
if(p->t_footing_final != NULL) {
if (p->t_footing_final != NULL) {
output_local ("&%s%d,",CB_PREFIX_REPORT_LINE,p->t_footing_final->id);
} else {
output_local("NULL,");
}
if(p->controls) {
if (p->controls) {
s = cb_code_field(p->controls);
output_local ("&%s%d_%d,",CB_PREFIX_REPORT_CONTROL,r_ctl_id,s->id);
} else {
output_local("NULL,");
}
if(sum_prv > 0) {
if (sum_prv > 0) {
output_local("&%s%d,",CB_PREFIX_REPORT_SUM_CTR,sum_prv);
} else {
output_local("NULL,");
Expand Down Expand Up @@ -12200,10 +12195,10 @@ pickup_c_param (cb_tree l, cob_u32_t inc, int is_enter)
}
} else {
if (is_enter) {
if(inc == 0) {
if (inc == 0) {
output_line ("if (cob_glob_ptr->cob_call_params >= 0)");
output_indent_level += 2;
} else if(inc > 0) {
} else if (inc > 0) {
output_line ("if (cob_glob_ptr->cob_call_params == 0");
output_line ("|| cob_glob_ptr->cob_call_params > %u)", inc);
output_indent_level += 2;
Expand All @@ -12215,7 +12210,7 @@ pickup_c_param (cb_tree l, cob_u32_t inc, int is_enter)
output ("; /* %s */", f->name);
output_newline ();
if (is_enter) {
if(inc >= 0)
if (inc >= 0)
output_indent_level -= 2;
}
}
Expand Down

0 comments on commit d212c67

Please sign in to comment.