Roger,
Yes, it looks not necessary.
For the test I've commented out return and replaced redefinition_error by
redefinition_warning.
Test went ok.
And here is the patch for the first issue (which is about
misaligned/missed levels)
G:\open-cobol\cobc>diff -u /open-cobol-0.33/cobc/field.c field.c
--- /open-cobol-0.33/cobc/field.c Sun Jan 08 08:00:00 2006
+++ field.c Tue Jan 17 18:12:36 2006
@@ -154,14 +154,35 @@
{
/* upper level */
struct cb_field *p;
- for (p = last_field->parent; p; p = p->parent)
- if (p->level == f->level)
- {
- last_field = p;
- goto same_level;
+ for (p = last_field->parent; p; p = p->parent) {
+ if (p->level == f->level)
+ {
+ last_field = p;
+ goto same_level;
+ }
+ if (p->level < f->level)
+ break;
+ }
+ if(p == NULL) { /* actually it can't be NULL so we can skip that */
+ cb_error_x (name, _("no previous data item of level
%02d"), f->level);
+ return cb_error_node;
+ } else {
+ cb_tree fil = cb_build_filler();
+ struct cb_reference *rfil = CB_REFERENCE (fil);
+ struct cb_field *ffil = CB_FIELD (cb_build_field (fil));
+ cb_warning_x (name, _("no previous data item of level
%02d"),f->level);
+ ffil->level = f->level;
+ ffil->storage = storage;
+ ffil->children = p->children;
+ ffil->parent = p;
+ for(p = p->children; p != NULL; p = p->sister) {
+ p->parent = ffil;
+ }
+ ffil->parent->children = ffil;
+ ffil->sister = f;
+ f->parent = ffil->parent;
+ last_field = ffil;
}
- cb_error_x (name, _("no previous data item of level %02d"), f->level);
- return cb_error_node;
}
/* inherit parent's properties */
----- Original Message ----- From: "Roger While" <address@hidden>
To: <address@hidden>
Cc: <address@hidden>
Sent: Wednesday, January 18, 2006 8:56 AM
Subject: Re: OC issues (more)
Well the problem is caused by this code in typeck.c line 302 :
if (CB_REFERENCE (name)->word->count > 0) {
cb_tree x = CB_VALUE (CB_REFERENCE (name)->word->items);
/* used as a non-label name or used as a section name or
used as the same paragraph name in the same section */
if (!CB_LABEL_P (x) || CB_LABEL (x)->section == NULL
|| CB_LABEL (x)->section == current_section) {
redefinition_error (name);
return cb_error_node;
}
The first test is OK (i think) but I wonder why we do the
subsequent tests ?
Hmm.
Uniqueness is checked later.
Roger