From bee0c45f08842a452bbc4e84baadf689226a4254 Mon Sep 17 00:00:00 2001 From: David Declerck Date: Mon, 15 Jul 2024 19:31:05 +0200 Subject: [PATCH] Merge SVN 4745 --- cobc/parser.y | 66 +++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/cobc/parser.y b/cobc/parser.y index b6986ca7c..83bcc79c7 100644 --- a/cobc/parser.y +++ b/cobc/parser.y @@ -7545,13 +7545,13 @@ picture_clause: } _pic_locale_format_or_depending_on { - if ((!current_field->pic || current_field->pic->variable_length) && - !current_field->flag_picture_l) { - /* Current field with PIC L was not translated */ - cb_error_x (CB_TREE (current_field->pic), + if ((!current_field->pic || current_field->pic->variable_length) && + !current_field->flag_picture_l) { + /* Current field with PIC L was not translated */ + cb_error_x (CB_TREE (current_field->pic), _("%s requires DEPENDING clause"), _("variable-length PICTURE")); - } + } } ; @@ -7559,34 +7559,37 @@ _pic_locale_format_or_depending_on: /* empty */ | LOCALE _is_locale_name SIZE _is integer { - /* $2 -> optional locale-name to be used */ - if ((current_field->pic->category != CB_CATEGORY_NUMERIC && - current_field->pic->category != CB_CATEGORY_NUMERIC_EDITED) || - strpbrk (current_field->pic->orig, " CRDBL-*") /* the standard seems to forbid also ',' */) { - cb_error_x (CB_TREE (current_field->pic), + /* $2 -> optional locale-name to be used */ + if ( (current_field->pic->category != CB_CATEGORY_NUMERIC + && current_field->pic->category != CB_CATEGORY_NUMERIC_EDITED) + || strpbrk (current_field->pic->orig, " CRDBL-*")) { + /* CHECKME: the standard seems to forbid additional ',' */ + cb_error_x (CB_TREE (current_field->pic), _("a locale-format PICTURE string must only consist of '9', '.', '+', 'Z' and the currency-sign")); - } else { - /* TODO: check that not we're not within a CONSTANT RECORD */ - CB_PENDING_X (CB_TREE (current_field->pic), "locale-format PICTURE"); - } + } else { + /* TODO: check that not we're not within a CONSTANT RECORD */ + CB_PENDING_X (CB_TREE (current_field->pic), "locale-format PICTURE"); + } } | DEPENDING _on reference { - cb_tree depending = $3; - if (!current_field->pic->variable_length) { - cb_error_x ($3, _("DEPENDING clause needs either an " + cb_tree depending = $3; + if (!current_field->pic->variable_length) { + cb_error_x ($3, _("DEPENDING clause needs either an " "OCCURS clause or a variable-length " "PICTURE")); - } else if (current_field->pic->category != CB_CATEGORY_ALPHABETIC && - current_field->pic->category != CB_CATEGORY_ALPHANUMERIC) { - cb_error_x ($3, _("only USAGE DISPLAY may specify a " + } else + if (current_field->pic->category != CB_CATEGORY_ALPHABETIC + && current_field->pic->category != CB_CATEGORY_ALPHANUMERIC) { + cb_error_x ($3, _("only USAGE DISPLAY may specify a " "variable-length PICTURE")); - } else if (current_storage == CB_STORAGE_SCREEN || - current_storage == CB_STORAGE_REPORT) { - cb_error_x ($3, _("%s not allowed in %s"), + } else + if (current_storage == CB_STORAGE_SCREEN + || current_storage == CB_STORAGE_REPORT) { + cb_error_x ($3, _("%s not allowed in %s"), _("variable-length PICTURE"), enum_explain_storage (current_storage)); - } else { + } else { /* Implicitly translate `PIC Lc... DEPENDING N` (where `c` may actually only be `X` or `A`) into a group with a single sub-field `PIC c OCCURS 1 TO N`. */ @@ -7603,11 +7606,11 @@ _pic_locale_format_or_depending_on: current_field->children = chld; cobc_parse_free (current_field->pic); current_field->pic = NULL; - } - /* Raise this flag in the error cases above, to avoid unrelated - warning or error messages upon tentative validation of - redefines. */ - current_field->flag_picture_l = 1; + } + /* Raise this flag in the error cases above, to avoid unrelated + warning or error messages upon tentative validation of + redefines. */ + current_field->flag_picture_l = 1; } ; @@ -17336,8 +17339,9 @@ _returning_national: ; _validating_with: -/* empty */ { $$ = NULL; } -| VALIDATING _with schema_file_or_record_name { $$ = $3; } +/* empty */ { $$ = NULL; } +| VALIDATING _with + schema_file_or_record_name { $$ = $3; } ; schema_file_or_record_name: