-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable is not referenced in report (SVN ticket : #863) #94
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Changes from 5 commits
78a6057
7b18452
610819d
7402d7b
bb2edcf
86c8cac
15ecc19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,6 +386,11 @@ | |
including "no identifier at all" and use of subscripting / ref-mod | ||
which previously were all silently ignored | ||
|
||
2023-03-14 Samuel Belondrade <[email protected]> | ||
|
||
* codegen.c (output_report_control): add a loop to check if the variable | ||
exist (bug: #863) | ||
|
||
2023-03-08 Emilien Lemaire <[email protected]> | ||
|
||
* reserved.c (get_user_specified_reserved_word): add check for | ||
|
@@ -429,7 +434,7 @@ | |
* pplex.l (ppinput): insert "preparse area_a token" in column 1 instead | ||
of column 2 to fix terminal-format support and insert it before | ||
newlines are added to the beginning of the buffer | ||
|
||
2023-02-21 Simon Sobisch <[email protected]> | ||
|
||
* codegen.c, flag.def [COBC_HAS_CUTOFF_FLAG]: fix compile errors, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9885,8 +9885,26 @@ output_report_control (struct cb_report *p, int id, cb_tree ctl, cb_tree nx) | |
x = CB_VALUE (ctl); | ||
s = cb_code_field(x); | ||
if(nx) { | ||
output_report_control(p, id, nx, CB_CHAIN(nx)); | ||
output_report_control (p, id, nx, CB_CHAIN(nx)); | ||
} | ||
|
||
bfound = 0; | ||
for(i= p->num_lines-1; i >= 0; i--) { | ||
if(p->line_ids[i]->report_control) { | ||
struct cb_field *c = cb_code_field (p->line_ids[i]->report_control); | ||
if(c == s) { | ||
bfound = 1; | ||
break; | ||
} | ||
} | ||
} | ||
if (!bfound) { | ||
cb_warning (COBC_WARN_FILLER, | ||
_("control field %s is not referenced in report"), s->name); | ||
p->controls = NULL; | ||
return ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work if there is a list of more than one controls, and the first one is not used. If you only issue a warning and not an error, your code has to handle correctly such a case. I would advise to clean up the controls at the beginning of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to clarify: |
||
} | ||
|
||
output_local("/* Report %s: CONTROL %s */\n",p->name,s->name); | ||
prvid = 0; | ||
for(i = 0; i < p->num_lines; i++) { | ||
|
@@ -9933,7 +9951,6 @@ output_report_control (struct cb_report *p, int id, cb_tree ctl, cb_tree nx) | |
} | ||
} | ||
if(!bfound) { | ||
printf("Control field %s is not referenced in report\n",s->name); | ||
output_local(",NULL"); | ||
} | ||
seq = i = 0; | ||
|
@@ -10229,7 +10246,8 @@ output_report_define_lines (int top, struct cb_field *f, struct cb_report *r) | |
if ((f->report_flag & COB_REPORT_LINE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (originating lines 10229-10235) This should be moved to typeck.c, at least the warning. |
||
&& f->children | ||
&& (f->children->report_flag & COB_REPORT_LINE)) { | ||
printf("Warning: Ignoring nested LINE %s %d\n", | ||
cb_warning (COBC_WARN_FILLER, | ||
_("ignoring nested LINE %s %d"), | ||
(f->report_flag & COB_REPORT_LINE_PLUS)?"PLUS":"", | ||
f->report_line); | ||
f->report_line = 0; | ||
|
@@ -10462,10 +10480,10 @@ output_report_definition (struct cb_report *p, struct cb_report *n) | |
output_local ("\n"); | ||
if(p->controls) { | ||
for (l = p->controls; l; l = CB_CHAIN (l)) { | ||
s = cb_code_field(l); | ||
s = cb_code_field (l); | ||
s->count++; | ||
} | ||
output_report_control(p,++r_ctl_id,p->controls,CB_CHAIN(p->controls)); | ||
output_report_control (p,++r_ctl_id,p->controls,CB_CHAIN(p->controls)); | ||
output_local ("\n"); | ||
} | ||
sum_prv = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9625,4 +9625,3 @@ BEFORE FINAL - SHOULD DISPLAY | |
], []) | ||
|
||
AT_CLEANUP | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -689,3 +689,50 @@ prog.cob:37: warning: non-numeric PICTURE clause for SUM WSI-V | |
|
||
AT_CLEANUP | ||
|
||
AT_SETUP([Check if the variable is referenced in the report]) | ||
AT_KEYWORDS([report]) | ||
|
||
AT_DATA([prog.cob], [ | ||
IDENTIFICATION DIVISION. | ||
PROGRAM-ID. MAIN. | ||
ENVIRONMENT DIVISION. | ||
CONFIGURATION SECTION. | ||
INPUT-OUTPUT SECTION. | ||
FILE-CONTROL. | ||
SELECT A_1 ASSIGN TO EXTERNAL A_1. | ||
SELECT A_2 ASSIGN TO EXTERNAL A_2. | ||
DATA DIVISION. | ||
FILE SECTION. | ||
FD A_1. | ||
COPY test. | ||
FD A_2 REPORT ETAT. | ||
WORKING-STORAGE SECTION. | ||
REPORT SECTION. | ||
RD ETAT | ||
CONTROL FINAL ERROR-1 ERROR-2 | ||
PAGE LIMIT 66. | ||
PROCEDURE DIVISION. | ||
STOP RUN. | ||
]) | ||
|
||
AT_DATA([test.cpy], [ | ||
01 TEST-01. | ||
03 TEST-03. | ||
88 TEST-88 VALUE "0000000". | ||
09 ERROR-1. | ||
88 E-TEST-1 VALUE "111". | ||
10 E-TEST-10 PIC 9(3). | ||
03 E-TEST-03. | ||
04 E-TEST-04. | ||
05 FILLER PIC X(21). | ||
88 E-TEST-2 VALUE " SM". | ||
03 E-TEST-2-03. | ||
09 ERROR-2 PIC 9(3). | ||
]) | ||
|
||
AT_CHECK([$COMPILE prog.cob], [0], [], | ||
[prog.cob: warning: control field ERROR-1 is not referenced in report | ||
prog.cob: warning: control field ERROR-2 is not referenced in report | ||
]) | ||
Comment on lines
+733
to
+736
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ideally should be changed to
|
||
|
||
AT_CLEANUP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check, the warning and likely also the setting to null (or dropping the single unused control, as @lefessan pointed out) must be moved to typeck.c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I moved this