-
Notifications
You must be signed in to change notification settings - Fork 26
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
Allow paragraph names to redefine field and section names #31
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Allow paragraph names to redefine field and section names #31
Conversation
It seems this is https://sourceforge.net/p/gnucobol/feature-requests/260 - in this case please check the discussion there and let us discuss the issue itself there (patches and changes here are still ok). |
8846569
to
b9125e9
Compare
(Marked as WIP as awaiting a rebase w.r.t |
You've likely done that - but the actual syntax test is missing; it should cover:
is there more? I think this can go "upstream" very soon, I guess you want to commit a GCOS base commit with NEWS entry and |
The test from the FR may be used - word.cob identification division.
program-id. word.
data division.
working-storage section.
*-----------------------------------------------------------------
77 word pic 9.
77 word2 pic x.
*-----------------------------------------------------------------
PROCEDURE DIVISION.
main section.
*
move 0 to word
perform word
*
exit program returning word.
*-----------------------------------------------------------------
entry "word2".
word section.
*
add 1 to word
if word = 2 goto word2.
add 1 to word.
*
word2.
*
continue.
*----------------------------------------------------------------- |
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.
Some minor adjustments needed, but nearly finished - the SF feature-request is now assigned to you, too :-)
b9125e9
to
1d1b32f
Compare
8677b94
to
ceaa925
Compare
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.
in general this could be either committed before or after the GCOS "base commit"
cobc/error.c
Outdated
default: | ||
return 0; | ||
} | ||
#ifndef _MSC_VER |
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 should not be necessary because of the default
above returns like all other paths. But if I remember correctly the "multiple case, then default" will raise a warning with different compilers, maybe drop that #ifndef
and the case
statements before the default?
Note: I'm always open to learn something new, maybe I've missed something?
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.
It's just an occurrence of careless copy-paste (I made this function by copying cb_verify_x
). Indeed the #ifndef should not be necessary.
I'm not aware of compilers specifically warning for falling through "into" the default case, though some compilers do have warnings (usually disabled) for fall-through in general.
Anyways, I'll just remove the default case and let the function return 0.
@@ -1938,8 +1938,15 @@ cb_build_section_name (cb_tree name, const int sect_or_para) | |||
if (!CB_LABEL_P (x) || sect_or_para == 0 || | |||
(sect_or_para && CB_LABEL_P (x) && | |||
CB_LABEL (x)->flag_section)) { | |||
redefinition_error (name); | |||
return cb_error_node; | |||
if (cb_is_supported(cb_non_unique_procedure_names) && |
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.
Shouldn't this be something like:
if ((CB_FIELD_P (x) ||
(CB_LABEL_P (x) && CB_LABEL (x)->flag_section))) {
cb_verify (cb_non_unique_procedure_names, _("non-unique procedure-name"));
} else {
redefinition_error (name);
return cb_error_node;
}
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.
I considered that first, but that would generate a different error message when a field or section name redefinition is forbidden by the non-unique-procedure-name
option being set to error
or unconformable
(I wanted the error message to remain the same, regardless of the reason why the redefinition is forbidden).
[prog.cob: in section 'L': | ||
prog.cob:6: warning: non-unique section or paragraph name used | ||
]) | ||
AT_CHECK([$COMPILE_ONLY -fnon-unique-procedure-names=error prog.cob], [1], [], | ||
[prog.cob: in section 'L': | ||
prog.cob:6: error: redefinition of 'L' | ||
prog.cob:5: note: 'L' previously defined here |
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.
the FIXME below can be removed
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.
Is everything of https://github.com/OCamlPro/gnucobol/pull/31#issuecomment-1137626598
already covered? If not then please add it as new testcase compiling once without std (expected warning with zero status) and with -std-cobol2002
(expecting error -> status 1)
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.
I've added the new test; for now it does not pass and reports an ambiguity. We are currently checking whether this one should indeed pass on GCOS.
On that note, the FR links to a former implementation are all broken. Is there another place where that previous attempt can be investigated?
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.
Ah, yes these are the old artifact links, just replace "open-cobol" in the URL with "gnucobol" to fix those manually.
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.
Ah yes indeed; somehow I had forgotten that was a former name for gnucobol.
Anyways, as far as our tests go, GCOS appears to subject uses of identical names for sections/paragraphs and data to syntactic scoping rules (as mentioned by David in the FR). This is the behavior of the current implementation.
For this reason we should expect the test cases imported from the FR to fail.
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.
If there's a section and a paragraph defined and you have PERFORM same-name
in GCOS that is auto-scoped?
So if you do it from main section
it will call the section with that name, but if you call it from other-section
that has the same-name
paragraph defined it uses that?
I'm a bit skeptic.
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.
If there's a section and a paragraph defined and you have
PERFORM same-name
in GCOS that is auto-scoped?
So if you do it frommain section
it will call the section with that name, but if you call it fromother-section
that has thesame-name
paragraph defined it uses that?
I'm a bit skeptic.
The part "what does GCOS do if there is both a section and a paragraph name with the same word" is the most important one not answered (or - totally possible: answered but I've overlooked that).
Would it be useful to go with a lesser version first that matches the old FR? This would be procedure-shares-data-name
or similar.
b7e3028
to
d9b858f
Compare
d9b858f
to
5a44c20
Compare
friendly ping |
Our migration project does not appear to require this anymore. As this may still be quite useful for other cases, I'll try to see if I can do something quick after a rebase/merge on |
friendly ping to recheck if this can be rebased and possibly "slimmed down" a bit for now
... actually it would then likely be more reasonable to start in a new (recent) branch and "only" add the "slimmed down" code there, handling the rebase here after we merged that new "slim" version |
This allows a paragraph to have the same name as a previous field or section.
It is not clear whether this is actually allowed or not by the standard or the GCOS dialect, however our customer does have Cobol programs where some paragraphs have the same name as fields or sections. Further discussion is probably required.
Below are the relevant excerpt from the standards for reference.
Both the COBOL 85 standard and GCOS say :
(nb: these rules say nothing about paragraphs)
The 2014 standard is a bit different :
The wording in item 3 is rather ambiguous...