-
Notifications
You must be signed in to change notification settings - Fork 40
Initial addition of CONSTANT SECTION #278
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
base: gitside-gnucobol-3.x
Are you sure you want to change the base?
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -3408,11 +3408,19 @@ cb_validate_field (struct cb_field *f) | |
| f->flag_invalid = 1; | ||
| return; | ||
| } | ||
| if (f->flag_item_78) { | ||
| if (f->flag_item_78) { | ||
| f->flag_is_verified = 1; | ||
| return; | ||
| } | ||
|
|
||
| if(f->storage == CB_STORAGE_CONSTANT){ | ||
| if(!f->values){ | ||
| cb_error(_("Items in CONSTANT SECTION must have VALUE ")); | ||
|
||
| } | ||
|
|
||
| CB_UNFINISHED ("CONSTANT SECTION code generation"); | ||
|
||
| } | ||
|
|
||
| /* Set up parameters */ | ||
| if (f->storage == CB_STORAGE_LOCAL || | ||
| f->storage == CB_STORAGE_LINKAGE || | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -297,7 +297,8 @@ enum cobc_hd { | |
| COBC_HD_LINKAGE_SECTION = (1U << 15), | ||
| COBC_HD_REPORT_SECTION = (1U << 16), | ||
| COBC_HD_SCREEN_SECTION = (1U << 17), | ||
| COBC_HD_PROCEDURE_DIVISION = (1U << 18) | ||
| COBC_HD_PROCEDURE_DIVISION = (1U << 18), | ||
| COBC_HD_CONSTANT_SECTION = (1U << 19) | ||
|
||
| }; | ||
|
|
||
| /* Static functions */ | ||
|
|
@@ -6437,6 +6438,7 @@ _data_division: | |
| _working_storage_section | ||
| _communication_section | ||
| _local_storage_section | ||
| _constant_section | ||
| _linkage_section | ||
| _report_section | ||
| _screen_section | ||
|
|
@@ -7403,7 +7405,7 @@ constant_entry: | |
| { | ||
| cb_tree x; | ||
| const int level = cb_get_level ($1); | ||
|
|
||
|
||
| cobc_cs_check = 0; | ||
| if (level != 1) { | ||
| cb_error (_("CONSTANT item not at 01 level")); | ||
|
|
@@ -9077,6 +9079,21 @@ _local_storage_section: | |
| } | ||
| ; | ||
|
|
||
| /* CONSTANT SECTION */ | ||
|
|
||
| constant_section: CONSTANT {check_area_a_of("CONSTANT SECTION");}; | ||
| _constant_section: | ||
|
|
||
| | constant_section SECTION _dot | ||
| { | ||
| check_headers_present(COBC_HD_DATA_DIVISION,0,0,0); // check for Data division before hand | ||
|
||
| header_check |= COBC_HD_CONSTANT_SECTION; | ||
| current_storage = CB_STORAGE_CONSTANT; | ||
| } | ||
| _record_description_list | ||
| ; | ||
|
|
||
|
|
||
|
|
||
| /* LINKAGE SECTION */ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1869,6 +1869,7 @@ struct cb_program { | |
| struct cb_field *linkage_storage; /* LINKAGE */ | ||
| struct cb_field *screen_storage; /* SCREEN */ | ||
| struct cb_field *report_storage; /* REPORT */ | ||
| struct cb_field *constant_storage; /* CONSTANT */ | ||
|
Collaborator
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. that is the right thing to add - but you'd have to add the fields to that as well and then "read" the fields from there later on (have a look how that is done with working_storage)
Author
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 I'm not exactly sure what should be added. I thought this is mainly for building the AST so I'm not particularly sure what is missing
Collaborator
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. When producing AST we have a "current storage" where fields are added to (a linked list of 01/77 fields) - I think while the current_storage is setup correctly, the assignment to add fields to that list isn't. When you add the new storage to those two places, you'll likely see that they are "empty". |
||
| cb_tree local_file_list; /* Local files */ | ||
| cb_tree global_file_list; /* Global files */ | ||
| struct handler_struct global_handler[5]; /* Global handlers */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2947,3 +2947,23 @@ AT_DATA([prog.cob], [ | |
|
|
||
| AT_CHECK([$COMPILE_ONLY -Wno-unfinished prog.cob], [0], [], []) | ||
| AT_CLEANUP | ||
|
|
||
|
|
||
| # CONSTANT SECTION | ||
| AT_SETUP([CONSTANT SECTION syntax]) | ||
| AT_KEYWORDS([extension constant VALUE]) | ||
|
|
||
| AT_DATA([prog.cob],[ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. TEST-NO-VALUE. | ||
| DATA DIVISION. | ||
| CONSTANT SECTION. | ||
| 01 NUM-CONST PIC 9(3). | ||
| PROCEDURE DIVISION. | ||
| STOP RUN. | ||
|
|
||
| ]) | ||
|
|
||
| AT_CHECK([$COMPILE_ONLY prog.cob], [1], [],[prog.cob:6: error: Items in CONSTANT SECTION must have VALUE | ||
| ]) | ||
| AT_CLEANUP | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,3 +752,25 @@ prog.cob:7: note: 'BIGFLT' defined here as USAGE FLOAT | |
|
|
||
| AT_CLEANUP | ||
|
|
||
|
|
||
|
|
||
| AT_SETUP([MOVE to CONSTANT SECTION item]) | ||
| AT_KEYWORDS([extension constant move]) | ||
|
|
||
| AT_XFAIL_IF([true]) | ||
|
||
|
|
||
| AT_DATA([prog.cob],[ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| CONSTANT SECTION. | ||
| 01 NUM-CONST PIC 9(3) VALUE 123. | ||
| PROCEDURE DIVISION. | ||
| MOVE 456 TO NUM-CONST | ||
| STOP RUN. | ||
| ]) | ||
|
|
||
| AT_CHECK([$COMPILE prog.cob], [1], [],[ignore]) | ||
|
Collaborator
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. you may add -Wno-unfinished to the command line - please add the expected error into stderr instead of ignore (see tests above how to split the AT_CHECK into multiple lines for that |
||
|
|
||
| AT_CLEANUP | ||
|
Comment on lines
+777
to
+797
Collaborator
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 test should be moved to run_extensions (with -Wno-unfinished in the compilation) and should include testing the actual result (which I guess will be fine); |
||
|
|
||
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'd have to check the rules but it could be that for a record structure only part of it needs a VALUE clause - I really don't know (the Fuji manual should have the rules in).