diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h index 7fc479da151e43d485b8d865f86c5eaf9ecf3402..9ca23b4150b0951aa3992ecf63a463b3181717d1 100644 --- a/gcc/cobol/cbldiag.h +++ b/gcc/cobol/cbldiag.h @@ -103,10 +103,10 @@ template <typename LOC> static void location_dump( const char func[], int line, const char tag[], const LOC& loc) { extern int yy_flex_debug; - if( yy_flex_debug && getenv("update_location") ) + if( yy_flex_debug && getenv("update_location") ) fprintf(stderr, "%s:%d: %s location (%d,%d) to (%d,%d)\n", - func, line, tag, - loc.first_line, loc.first_column, loc.last_line, loc.last_column); + func, line, tag, + loc.first_line, loc.first_column, loc.last_line, loc.last_column); } #endif // defined(yy_flex_debug) diff --git a/gcc/cobol/cdf-copy.cc b/gcc/cobol/cdf-copy.cc index a7c95e1db75ed7b4d0d325dff5c7cdaab8a1b15d..6b1901e90dac96d0606266fc7a3666bc08de685c 100644 --- a/gcc/cobol/cdf-copy.cc +++ b/gcc/cobol/cdf-copy.cc @@ -278,20 +278,20 @@ copybook_elem_t::open_file( const char directory[], bool literally ) { } else { const char *dir = directory? directory : library.name; path = xasprintf( "%s/%s", dir, source.name ); - } + } } else { path = xasprintf( "%s", source.name ); } gcc_assert(path); - + if( literally ) { dbgmsg("copybook_elem_t::open_file: trying %s", path); if( (this->fd = open(path, O_RDONLY)) == -1 ) { dbgmsg("could not open %s: %m", path); return fd; - } + } this->source.name = path; if( ! cobol_filename(this->source.name, inode_of(fd)) ) { error_msg(source.loc, "recursive copybook: '%s' includes itself", path); @@ -301,7 +301,7 @@ copybook_elem_t::open_file( const char directory[], bool literally ) { return fd; } gcc_assert( ! literally ); - + if( extensions ) { pattern = xasprintf("%s{,.cpy,.CPY,.cbl,.CBL,.cob,.COB,%s}", path, this->extensions); diff --git a/gcc/cobol/copybook.h b/gcc/cobol/copybook.h index 81a2b27eda1e71043972e31419854b676eac5630..3e2cf9d934e86e210374b2fe9620f61000482bbb 100644 --- a/gcc/cobol/copybook.h +++ b/gcc/cobol/copybook.h @@ -92,7 +92,7 @@ class copybook_elem_t { int open_file( const char dir[], bool literally = false ); void extensions_add( const char ext[], const char alt[] ); - + static inline bool is_quote( const char ch ) { return ch == '\'' || ch == '"'; } @@ -145,7 +145,7 @@ class copybook_t { } if( false && value != uname ) { dbgmsg("using copybook file '%s' from environment variable '%s'", - value, name); + value, name); } return xstrdup(value); } @@ -184,9 +184,9 @@ class copybook_t { for( auto dir : directories ) { if( true ) { dbgmsg("copybook_t::open '%s' OF '%s' %s", - book.source.name, - dir? dir: ".", - book.literally.source? ", literally" : "" ); + book.source.name, + dir? dir: ".", + book.literally.source? ", literally" : "" ); } if( (fd = book.open_file(dir, book.literally.source)) != -1 ) break; } diff --git a/gcc/cobol/gcobc b/gcc/cobol/gcobc index 74f54a4ef9f18e2d9dc1b522d24bf963d7166ca8..93e1bd302a66fadd3504626beb329042d27e4ca6 100755 --- a/gcc/cobol/gcobc +++ b/gcc/cobol/gcobc @@ -150,9 +150,9 @@ do case $opt in -A | -Q) warn "$opt" ;; - -b) mode="-shared" + -b) mode="-shared" ;; - -c) mode="-c" + -c) mode="-c" ;; --conf=*) warn "$opt" ;; @@ -161,8 +161,8 @@ do -d | --debug) opts="$opts -fcobol-exceptions=EC-ALL" warn "$opt implies -fstack-check:" ;; - # -D - -E) opts="$opts $opt -fsyntax-only" + # -D + -E) opts="$opts $opt -fsyntax-only" ;; -echo) echo="echo" ;; @@ -367,7 +367,7 @@ do opts="$opts -ffree-form" ;; - -h | --help) opts="$opts --help" + -h | --help) opts="$opts --help" ;; -HELP) help && exit @@ -375,7 +375,7 @@ do -i | --info) warn "$opt" ;; - # -I + # -I -fimplicit-init) warn "$opt" ;; -j | -job) warn "$opt" @@ -384,26 +384,26 @@ do ;; -K*) warn "$opt" ;; - # -l - # -L + # -l + # -L --list*) warn "$opt" ;; - -m) mode="-shared" + -m) mode="-shared" ;; # -main # -nomain - # -o + # -o # -O0, -Ox -O | -O2 | -Os) warn "$opt" ;; - -S) mode="$opt" + -S) mode="$opt" ;; -save-temps=*) opt="$(echo "$opt" | sed -E 's/^.+=//')" export GCOBOL_TEMPDIR="$opt" ;; -save-temps) export GCOBOL_TEMPDIR="${PWD:-$(pwd)}" ;; - # -shared is identical + # -shared is identical -std=mvs) opts="$opts -dialect ibm" ;; diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1 index 415ad36aa786398ae69a91148ea9ebfdfff5a411..64c017c221449a2aa3977c314dceee987146d47a 100644 --- a/gcc/cobol/gcobol.1 +++ b/gcc/cobol/gcobol.1 @@ -64,18 +64,18 @@ will include a entry point calling the first PROGRAM-ID in .Ar filename .It Fl main Ns Li = Ns Ar filename:program-id -The .o object module for +The .o object module for .Ar filename -will include a +will include a .Fn main -entry point that calls the +entry point that calls the .Ar program-id entry point .It Fl nomain No .Fn main entry point will be generated by this -compilation. The +compilation. The .Fl nomain option is incompatible with .Fl main , @@ -83,11 +83,11 @@ and is implied by .Fl shared . It is also implied by .Fl c -when there is no +when there is no .Fl main present. .Pp -See below for examples showing the use of +See below for examples showing the use of .Fl main and .Fl nomain. @@ -104,7 +104,7 @@ line-number consistency with the input, blank lines are retained. .Pp Unlike the C compiler, This option does not prevent compilation. To prevent compilation, use the option -.D1 Fl Sy fsyntax-only +.D1 Fl Sy fsyntax-only also. .It Fl fdefaultbyte Ns Li = Ns Ar value Use @@ -118,7 +118,7 @@ items are initialized to zero. This option overrides the default with Invoke only the parser. Check the code for syntax errors, but don't do anything beyond that. .It Fl copyext Ar ext -For the CDF directive +For the CDF directive .D1 COPY Ar name if .Ar name @@ -135,7 +135,7 @@ If is all uppercase or all lowercase, both forms are tried, with preference given to the one supplied. If .Ar ext is mixed-case, only that version is tried. -For example, with +For example, with .D1 Fl copyext Ar .abc given the CDF directive .D1 COPY name @@ -144,7 +144,7 @@ will add to possible names searched .Ql name.abc and .Ql name.ABC -in that order. +in that order. .It Fl ffixed-form Use strict .Em "Reference Format" @@ -192,7 +192,7 @@ auto-detects the source code format by examining the of the first line of the first file: if those characters are all digits or blanks, the file is assumed to be in .Em "reference format" , -with the indicator area in column 7. +with the indicator area in column 7. .Pp . .It Fl fcobol-exceptions Ar exception Op Ns , Ns Ar exception Ns ... @@ -203,8 +203,8 @@ CDF directive. This option enables one or more exception conditions by default, as though .Sy TURN -had appeared at the top of the first source code file. -This option may also appear more than once on the command line. +had appeared at the top of the first source code file. +This option may also appear more than once on the command line. .Pp The value of .Ar exception @@ -327,13 +327,13 @@ each .Ar preprocess-filter reads from standard input and writes to standard output. .Pp -To supply options to +To supply options to .Ar preprocess-filter , use a comma-separated string, similar to how linker options are supplied to .Fl Sy Wl . (Do not put any spaces after the commas, because the shell will treat it as an option separator.) .Nm -replaces each comma with a space when +replaces each comma with a space when .Ar preprocess-filter is invoked. For example, .D1 Fl preprocess Li tee,output.cbl @@ -352,11 +352,11 @@ and the compiler is not invoked. .Pp The .Fl preprocess -option may appear more than once on the command line. Each +option may appear more than once on the command line. Each .Ar preprocess-filter -is applied in turn, in order of appearance. +is applied in turn, in order of appearance. .Pp -The +The .Ar preprocess-filter should return a zero exit status, indicating success. If it returns a nonzero exit status, an error is reported and the compiler is not @@ -376,7 +376,7 @@ option shows the shift and reduce actions taken by the parser. .D1 gcobol -main= Ns Ar xyz.cob Ar xyz.cob These are equivalent. The .Ar xyz.cob -code is compiled and a +code is compiled and a .Fn main function is inserted that calls the first PROGRAM-ID in the @@ -386,10 +386,10 @@ source file. .D1 gcobol -nomain Ar xyz.cob Ar elsewhere.o The .Fl nomain -option prevents a +option prevents a .Fn main function from being generated by the gcobol compiler. -A +A .Fn main entry point must be present in the .Ar elsewhere.o @@ -433,7 +433,7 @@ file will contain a entry point that calls the first PROGRAM-ID in .Ar bbb . The fourth links the three .o files into an -.Ar a.out . +.Ar a.out . . .Sh EBCDIC The @@ -583,7 +583,7 @@ The following are implemented: .Pp .Bl -tag -offset 5n -compact .It EC-FUNCTION-ARGUMENT -for the following functions: +for the following functions: .Bl -item -compact .It ACOS @@ -617,8 +617,8 @@ for both fixed-point and floating-point division .El .Pp As of this writing, no \*[lang] compiler documents a complete -implementation of \*[isostd] Exception Conditions. -.Nm +implementation of \*[isostd] Exception Conditions. +.Nm will give priority to those ECs that the user community deems most valuable. . @@ -710,7 +710,7 @@ argument, the target is set to .Sy LOW-VALUES . .Pp The system command line parameters can also be accessed through the LINKAGE -SECTION in the program where execution starts. The data structure looks like +SECTION in the program where execution starts. The data structure looks like this: .Bd -literal linkage section. @@ -798,7 +798,7 @@ types, most of which alias LB LB LB LB LB LB LB LB L L L L . -COMP-5 Compatible +COMP-5 Compatible Picture BINARY Type Bytes Value T{ BINARY-CHAR [UNSIGNED] @@ -868,7 +868,7 @@ supports the ISO syntax for returning an exit status to the operating system, .Pp .D1 STOP RUN Oo WITH Oc Bro NORMAL | ERROR Brc Oo STATUS Oc Ar status .Pp -In addition, +In addition, .Nm also supports the IBM syntax for returning an exit status to the operating system. Use the @@ -916,9 +916,9 @@ as a compilation variable to have the value .Ar expression . If .Ar name -was previously defined, +was previously defined, .Sy OVERRIDE -is required, else the directive is invalid. +is required, else the directive is invalid. .Sy AS PARAMETER is accepted, but has no effect in .Nm . @@ -927,9 +927,9 @@ is accepted, but has no effect in releases the definition .Ar name , making it subsequently invalid for use. -.\" ISO requires AS; cdf.y does not. +.\" ISO requires AS; cdf.y does not. . -.It >> Ns Sy IF Ar cce Ar text Oo >> Ns Sy ELSE Ar alt-text Oc Li >> Ns Sy END-IF +.It >> Ns Sy IF Ar cce Ar text Oo >> Ns Sy ELSE Ar alt-text Oc Li >> Ns Sy END-IF evaluates .Ar cce , a @@ -943,7 +943,7 @@ command-line parameter. If true, the \*[lang] text .Ar text is compiled. If false, .Ar else-text , -if present, is compiled. +if present, is compiled. .Bo Sy IS Bo Sy NOT Bc Bc Sy DEFINED is supported. Boolean literals are not supported. . @@ -952,7 +952,7 @@ Not implemented. .El . .Ss Other CDF Directives -.Bl -tag -width >>PROPAGATE +.Bl -tag -width >>PROPAGATE .It >> Ns Sy CALL-CONVENTION Ar convention .Ar convention may be one of: @@ -971,20 +971,20 @@ An alias for >>\c .Sy "CALL-CONVENTION C" . .El .It >> Ns Sy COBOL-WORDS EQUATE Ar keyword Sy WITH Ar alias -makes +makes .Ar alias -a synonym for +a synonym for .Ar keyword . .It >> Ns Sy COBOL-WORDS UNDEFINE Ar keyword .Ar keyword is removed from the \*[lang] grammar. Use of it in a program will provoke -a syntax error from the compiler. +a syntax error from the compiler. .It >> Ns Sy COBOL-WORDS SUBSTITUTE Ar keyword Sy BY Ar new-word .Ar keyword is deleted as a keyword from the grammar, replaced by .Ar new-word . .Ar keyword -may thereafter be used as a user-defined word. +may thereafter be used as a user-defined word. .It >> Ns Sy COBOL-WORDS RESERVE Ar new-word Treat .Ar new-word @@ -994,7 +994,7 @@ keyword or as a user-defined word. .It >> Ns Sy DISPLAY Ar string ... Write .Ar string -to standard error as a warning message. +to standard error as a warning message. .It >> Ns Sy SOURCE Ar format .Ar format may be one of: @@ -1042,7 +1042,7 @@ statement that triggered the exception condition. . .Ss Feature-set Variables Some command-line options affect CDF -.Em "feature-set" +.Em "feature-set" variables that are special to .Nm . They can be set and tested using @@ -1072,7 +1072,7 @@ the directive must appear before .Sy PROGRAM-ID . .Pp To test a feature-set variable, use -.Dl >>IF Ar feature Li DEFINED +.Dl >>IF Ar feature Li DEFINED .. .Ss Copybooks .Nm @@ -1359,7 +1359,7 @@ If defined, specifies the directory paths to be used by the runtime library, .Pa libgcobol.so , to locate shared objects. -Like +Like .Ev LD_LIBRARY_PATH , it may contain several directory names separated by a colon .Pq Ql \&: . @@ -1373,7 +1373,7 @@ For each such file, .Xr dlopen 3 is attempted, and, if successful .Xr dlsym 3 . -No relationship is defined between the symbol's name and the filename. +No relationship is defined between the symbol's name and the filename. .Pp Without .Ev COBPATH , @@ -1383,7 +1383,7 @@ behave as one might expect of any program compiled with gcc. Any shared objects needed by the program are mentioned on the command line with a .Fl l Ns Ar library -option, and are found by following the executable's +option, and are found by following the executable's .Pa RPATH or otherwise per the configuration of the runtime linker, .Xr ld.so 8 . diff --git a/gcc/cobol/gcobol.3 b/gcc/cobol/gcobol.3 index a9bed854c820d8efb4fb51c795f115fe42c22cf2..adc141a7aadcdc920833978ba34e27277155c6d5 100644 --- a/gcc/cobol/gcobol.3 +++ b/gcc/cobol/gcobol.3 @@ -61,7 +61,7 @@ implement sequential, relative, and indexed file operations over files whose On Disk Format (ODF) is defined by .Nm . A user wishing to use another library that implements the same -functionality over a different ODF must supply a different implementation of +functionality over a different ODF must supply a different implementation of .Fn gcobol_fileops , plus 7 functions, as described in this document. The pointers to those user-implemented functions are placed in a C++ object of type @@ -69,10 +69,10 @@ those user-implemented functions are placed in a C++ object of type and an instantiation of that type is returned by .Fn gcobol_fileops . The compiled program initializes I/O operations by calling that -function the first time any file is opened. +function the first time any file is opened. .Pp Each function takes as its first argument a pointer to a -.Vt cblc_file_t +.Vt cblc_file_t object, which is analogous to a .Vt FILE object used in the C @@ -85,7 +85,7 @@ there. Notably, the outcome of any operation is stored in that structure in the .Va file_status member, not as a return code. Information about the -.Em operation +.Em operation (as opposed to the .Em file ) appear as parameters to the function. @@ -99,14 +99,14 @@ that is reserved for the user: User-supplied I/O functions may assign and dereference .Pa implementation . .Nm -will preserve the value, but never references it. +will preserve the value, but never references it. .Pp The 7 function pointers in .Vt gcobol_io_t are .Bl -hang -width Rewrite .It Open -.Ft void +.Ft void .Fn open_t "cblc_file_t *file" "char *filename" "int mode_char" "int is_quoted" .br parameters: @@ -161,7 +161,7 @@ parameters: .It Ar relop is one of .Bl -hang -width LT -compact -.It Li 0 +.It Li 0 means .Sq < .It Li 1 @@ -183,7 +183,7 @@ means .It Ar first_last_key is the key number (starting at 1) of the key within the .Vt cblc_file_t -structure. +structure. .It Ar length is the size of the key (TODO: per the START statement?) .El @@ -201,7 +201,7 @@ NEXT .It Ar \0N represents a key number, starting with 1, in the .Vt cblc_file_t -structure. The value of that key is used to find the record, and read it. +structure. The value of that key is used to find the record, and read it. .El .El .It Write @@ -216,7 +216,7 @@ address of in-memory buffer to write .It Ar length length of in-memory buffer to write .It Ar after -has the value 1 if the +has the value 1 if the .D1 "AFTER ADVANCING n LINES" phrase was present in the .Sy WRITE @@ -288,7 +288,7 @@ This function populates a object with the above function pointers. The compiled binary begins by calling .Fn gcobol_fileops Ns , -and then uses the supplied pointers to effect I/O. +and then uses the supplied pointers to effect I/O. .El . .\" The following commands should be uncommented and @@ -317,12 +317,12 @@ It is not intended to be compatible with any other ODF. That is, .Sy libgcobolio.so cannot be used to exchange data with any other \*[lang] implementation. .Pp -The purpose of the +The purpose of the .Vt gcobol_io_t structure is to allow the use of other I/O implementations with other ODF representations. .\" .Sh HISTORY .\" .Sh AUTHORS .Sh CAVEATS -The library is not well tested, not least because it is not implemented. +The library is not well tested, not least because it is not implemented. .Sh BUGS -The future is yet to come. +The future is yet to come. diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 9c2ab8ad207a7fb8b1aa174aec23ed646049f201..ef3fdfd206870c967ee634d258c987fe4675499c 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -233,7 +233,7 @@ create_cblc_string_variable(const char *var_name, const char *var_contents) // This is a way of having the compiler communicate with GDB. I create a // global const char[] string with a known name so that GDB can look for that // variable and pick up its contents. - + // This probably should be in the .debug_info section, but for the moment I // don't know how to do that, but I do know how to do this: @@ -1450,7 +1450,7 @@ get_bytes_needed(cbl_field_t *field) } if( !(field->attr & separate_e) ) { - // This is COMP-3, so there is a sign nybble. + // This is COMP-3, so there is a sign nybble. digits += 1; } retval = (digits+1)/2; @@ -3256,7 +3256,7 @@ parser_first_statement( int lineno ) { // In the event that this routine is the one that main() calls to get the // execution ball rolling, we want the GDB "start" function to be able - // to set a temporary breakpoint at this location. We get that rolling + // to set a temporary breakpoint at this location. We get that rolling // here. char ach[256]; @@ -3269,7 +3269,7 @@ parser_first_statement( int lineno ) SHOW_PARSE_END } - if( strcmp(current_function->our_name, ach_cobol_entry_point) == 0 + if( strcmp(current_function->our_name, ach_cobol_entry_point) == 0 && !suppress_cobol_entry_point ) { sprintf(ach, @@ -3580,7 +3580,7 @@ parser_enter_program( const char *funcname_, if( strcmp(funcname_, "main") == 0 && this_module_has_main ) { - // setting 'retval' to 1 let's the caller know that we are being told + // setting 'retval' to 1 let's the caller know that we are being told // both to synthesize a main() entry point to duplicate GCC's default // behavior, and to create an explicit entry point named "main". This will // eventually result in a link error (because of the duplicated entry @@ -4125,7 +4125,7 @@ parser_accept( struct cbl_refer_t refer, NULL_TREE); } -// TODO: update documentation. +// TODO: update documentation. void parser_accept_exception( cbl_label_t *accept_label ) { @@ -4207,7 +4207,7 @@ parser_accept_command_line( cbl_refer_t tgt, if( !source.field ) { // The whole command-line is wanted - gg_assign(erf, + gg_assign(erf, gg_call_expr( INT, "__gg__get_command_line", gg_get_address_of(tgt.field->var_decl_node), @@ -4217,7 +4217,7 @@ parser_accept_command_line( cbl_refer_t tgt, if( error ) { // There is an ON EXCEPTION phrase: - IF( erf, ne_op, integer_zero_node ) + IF( erf, ne_op, integer_zero_node ) { SHOW_PARSE { @@ -4235,7 +4235,7 @@ parser_accept_command_line( cbl_refer_t tgt, if( not_error ) { // There is an NOT ON EXCEPTION phrase: - IF( erf, eq_op, integer_zero_node ) + IF( erf, eq_op, integer_zero_node ) { SHOW_PARSE { @@ -4254,7 +4254,7 @@ parser_accept_command_line( cbl_refer_t tgt, else { // A particular parameter has been requested: - gg_assign(erf, + gg_assign(erf, gg_call_expr( INT, "__gg__get_argv", gg_get_address_of(tgt.field->var_decl_node), @@ -4267,7 +4267,7 @@ parser_accept_command_line( cbl_refer_t tgt, if( error ) { // There is an ON EXCEPTION phrase: - IF( erf, ne_op, integer_zero_node ) + IF( erf, ne_op, integer_zero_node ) { SHOW_PARSE { @@ -4285,7 +4285,7 @@ parser_accept_command_line( cbl_refer_t tgt, if( not_error ) { // There is an NOT ON EXCEPTION phrase: - IF( erf, eq_op, integer_zero_node ) + IF( erf, eq_op, integer_zero_node ) { SHOW_PARSE { @@ -4388,7 +4388,7 @@ parser_accept_envar(struct cbl_refer_t tgt, if( error ) { // There is an ON EXCEPTION phrase: - IF( erf, ne_op, integer_zero_node ) + IF( erf, ne_op, integer_zero_node ) { gg_append_statement( error->structs.arith_error->into.go_to ); } @@ -4400,7 +4400,7 @@ parser_accept_envar(struct cbl_refer_t tgt, if( not_error ) { // There is an NOT ON EXCEPTION phrase: - IF( erf, eq_op, integer_zero_node ) + IF( erf, eq_op, integer_zero_node ) { gg_append_statement( not_error->structs.arith_error->into.go_to ); } @@ -5834,7 +5834,7 @@ parser_exit_program(void) // exits back to COBOL only, else continue /* * If RETURNING was specified, the field is provided as an argument, no lookup * necessary. refer.field == NULL means exit(0) unless ec != ec_none_e. - * If ec == ec_all_e, that indicates RAISING LAST EXCEPTION was used. + * If ec == ec_all_e, that indicates RAISING LAST EXCEPTION was used. */ static @@ -5843,7 +5843,7 @@ pe_stuff(cbl_refer_t refer, ec_type_t ec) { // This is the moral equivalent of a C "return xyz;". - // There cannot be both a non-zero exit status and an exception condition. + // There cannot be both a non-zero exit status and an exception condition. gcc_assert( !(ec != ec_none_e && refer.field != NULL) ); gg_call(VOID, @@ -5937,7 +5937,7 @@ parser_exit( cbl_refer_t refer, ec_type_t ec ) { SHOW_PARSE_HEADER if( gg_trans_unit.function_stack.size() - && current_function->returning + && current_function->returning && !refer.field) { // ->returning works only if there is no refer.field @@ -5951,7 +5951,7 @@ parser_exit( cbl_refer_t refer, ec_type_t ec ) { SHOW_PARSE_TEXT(" refer.prog_func is non-zero") } - + SHOW_PARSE_END } TRACE1 @@ -6693,8 +6693,8 @@ parser_division(cbl_division_t division, cbl_ffi_crv_t crv = args[i].crv; cbl_field_t *new_var = args[i].refer.field; - - if( crv == by_value_e ) + + if( crv == by_value_e ) { switch(new_var->type) { @@ -6708,7 +6708,7 @@ parser_division(cbl_division_t division, break; } } - + if( crv == by_value_e ) { // 'parameter' is the 64-bit or 128-bit value that was placed on the stack @@ -7524,7 +7524,7 @@ parser_perform(struct cbl_perform_tgt_t *tgt, struct cbl_refer_t how_many) { // There is no N. This is PERFORM proc-1 THROUGH proc-2 // false means nexting in GDB will work - internal_perform_through(tgt->from(), tgt->to(), false); + internal_perform_through(tgt->from(), tgt->to(), false); } else { @@ -8094,7 +8094,7 @@ perform_outofline_before_varying( struct cbl_perform_tgt_t *tgt, // for the generated runtime code to reach this point except by jumpint to // the EXIT: label. // We have, you see, reached the egress: - gg_append_statement( tgt->addresses.exit.label ); + gg_append_statement( tgt->addresses.exit.label ); sprintf(ach, "_procretb.%ld:", our_pseudo_label); @@ -8715,7 +8715,7 @@ parser_perform_inline_times(struct cbl_perform_tgt_t *tgt, } int stash = gg_get_current_line_number(); - gg_set_current_line_number(tgt->addresses.line_number_of_setup_code); + gg_set_current_line_number(tgt->addresses.line_number_of_setup_code); gg_append_statement( tgt->addresses.setup.label ); // Get the count: @@ -8746,7 +8746,7 @@ parser_perform_inline_times(struct cbl_perform_tgt_t *tgt, gg_append_statement( tgt->addresses.exit.go_to ); ENDIF - gg_set_current_line_number(stash); + gg_set_current_line_number(stash); SHOW_PARSE { @@ -12125,7 +12125,7 @@ create_and_call(size_t narg, for( size_t i=0; i<narg; i++ ) { cbl_ffi_crv_t crv = args[i].crv; - + if( args[i].refer.field && args[i].refer.field->type == FldLiteralN ) { crv = by_value_e; @@ -12194,7 +12194,7 @@ create_and_call(size_t narg, && is_valuable(args[i].refer.field->type) ) { cbl_unimplemented("CALL USING BY CONTENT <temporary> would require " - "REPOSITORY PROTOTYPES."); + "REPOSITORY PROTOTYPES."); } // BY CONTENT means that the called program gets a copy of the data. @@ -15551,11 +15551,11 @@ initial_from_float128(cbl_field_t *field, _Float128 value) // For COMP-6 (flagged by separate_e), the number of required digits is // twice the capacity. - + // For COMP-3, the number of digits is 2*capacity minus 1, because the // the final "digit" is a sign nybble. - size_t ndigits = (field->attr & separate_e) + size_t ndigits = (field->attr & separate_e) ? field->data.capacity * 2 : field->data.capacity * 2 - 1; digits_from_float128(ach, field, ndigits, rdigits, value); @@ -15664,7 +15664,7 @@ initial_from_float128(cbl_field_t *field, _Float128 value) memset(ach, 0, sizeof(ach)); memset(retval, 0, field->data.capacity); size_t ndigits = field->data.capacity; - + if( (field->attr & blank_zero_e) && value == 0 ) { memset(retval, internal_space, field->data.capacity); @@ -16313,7 +16313,7 @@ parser_symbol_add(struct cbl_field_t *new_var ) if( new_var->data.memsize < new_var->data.capacity * new_var->occurs.bounds.upper ) { cbl_internal_error("LEVEL 01 (%s) OCCURS " - "has insufficient data.memsize", new_var->name); + "has insufficient data.memsize", new_var->name); } } @@ -16392,9 +16392,9 @@ parser_symbol_add(struct cbl_field_t *new_var ) TRACE1_HEADER if( new_var->level ) { - gg_fprintf( trace_handle, - 1, - "%2.2d ", + gg_fprintf( trace_handle, + 1, + "%2.2d ", build_int_cst_type(INT, new_var->level)); } TRACE1_TEXT(new_var->name) @@ -16403,7 +16403,7 @@ parser_symbol_add(struct cbl_field_t *new_var ) { gg_fprintf( trace_handle, 1, " [%ld]", - build_int_cst_type(LONG, + build_int_cst_type(LONG, *(const long *)new_var->data.initial)); } TRACE1_END @@ -16915,5 +16915,4 @@ parser_symbol_add(struct cbl_field_t *new_var ) } done: return; - } - + } diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc index f044d45e530593130918c9e329c14548444eb439..b84c3fa0fc98a8cfd40b581f02bcdc62f3e20f37 100644 --- a/gcc/cobol/gengen.cc +++ b/gcc/cobol/gengen.cc @@ -846,7 +846,7 @@ gg_struct_field_ref(const tree base, const char *field) tree type = TREE_TYPE(base); if( POINTER_TYPE_P (type) ) { - tree pointer_type = TREE_TYPE(base); + tree pointer_type = TREE_TYPE(base); tree base_pointer_type = TREE_TYPE(pointer_type); // We need a COMPONENT_REF which is an INDIRECT_REF to a FIELD_DECL tree field_decl = gg_find_field_in_struct(base, field); @@ -1095,7 +1095,7 @@ gg_define_variable(tree type_decl, gg_variable_scope_t vs_scope) } tree -gg_define_variable( tree type_decl, +gg_define_variable( tree type_decl, const char *var_name, gg_variable_scope_t vs_scope, tree initial_value) @@ -1620,7 +1620,7 @@ static tree gg_get_larger_type(tree A, tree B) { tree larger = TREE_TYPE(B); - if( TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(A))) + if( TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(A))) > TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(B))) ) { larger = TREE_TYPE(A); @@ -2171,8 +2171,8 @@ gg_printf(const char *format_string, ...) // Because we don't actually use stderr ourselves, we just pick it up as a // VOID_P and pass it along to fprintf() - tree t_stderr = gg_declare_variable(VOID_P, "stderr", - NULL_TREE, + tree t_stderr = gg_declare_variable(VOID_P, "stderr", + NULL_TREE, vs_external_reference); gg_push_context(); @@ -2258,7 +2258,7 @@ gg_fprintf(tree fd, int nargs, const char *format_string, ...) va_end (ap); static tree function = NULL_TREE; - + if( !function ) { function = gg_get_function_address(INT, "sprintf"); @@ -2310,7 +2310,7 @@ gg_write(tree fd, tree buf, tree count) void gg_memset(tree dest, const tree value, tree size) { - tree the_call = + tree the_call = build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_MEMSET), 3, @@ -2323,7 +2323,7 @@ gg_memset(tree dest, const tree value, tree size) tree gg_memchr(tree buf, tree ch, tree length) { - tree the_call = fold_convert( + tree the_call = fold_convert( pvoid_type_node, build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_MEMCHR), @@ -2387,7 +2387,7 @@ gg_memdup(tree data, size_t length) void gg_strcpy(tree dest, tree src) { - tree the_call = + tree the_call = build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_STRCPY), 2, @@ -2399,7 +2399,7 @@ gg_strcpy(tree dest, tree src) tree gg_strcmp(tree A, tree B) { - tree the_call = fold_convert( + tree the_call = fold_convert( integer_type_node, build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_STRCMP), @@ -2431,7 +2431,7 @@ gg_close(tree int_A) tree gg_strncmp(tree char_star_A, tree char_star_B, tree size_t_N) { - tree the_call = fold_convert( + tree the_call = fold_convert( integer_type_node, build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_STRNCMP), @@ -2446,7 +2446,7 @@ void gg_return(tree operand) { tree stmt; - + if( !gg_trans_unit.function_stack.size() ) { // I put this in to cope with the problem of two END PROGRAM statements, which @@ -2696,7 +2696,7 @@ gg_define_function(tree return_type, const char *funcname, ...) if(nparams > ARG_LIMIT) { yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ ); - yywarn("###### %d parameters? Really? Are you insane?", + yywarn("###### %d parameters? Really? Are you insane?", ARG_LIMIT+1); gcc_assert(false); } @@ -3002,7 +3002,7 @@ gg_push_context() // We are creating the initial context of the function: DECL_INITIAL(current_function->function_decl) = block; DECL_SAVED_TREE(current_function->function_decl) = bind_expr; - + // To avoid an N-squared time complexity when chaining blocks, we save the // current end of the chain of blocks: current_function->current_block = block; @@ -3051,7 +3051,7 @@ function_decl_from_name(tree return_type, tree arg_types[]) { tree fndecl; - std::unordered_map<std::string, tree>::const_iterator it = + std::unordered_map<std::string, tree>::const_iterator it = fndecl_from_name.find(function_name); if( it != fndecl_from_name.end() ) { @@ -3076,12 +3076,12 @@ gg_call_expr(tree return_type, const char *function_name, ...) // tree call_expr = gg_call_expr(...); // gg_assign( dest, call_expr ); - + // Note that everyt time call_expr is laid down, the function will be called, // so you probably don't want to do things like // gg_assign( dest1, call_expr ); // gg_assign( dest2, call_expr ); - + int nargs = 0; static tree arg_types[ARG_LIMIT+1]; static tree args[ARG_LIMIT+1]; @@ -3236,7 +3236,7 @@ gg_create_bind_expr() void gg_exit(tree exit_code) { - tree the_call = + tree the_call = build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_EXIT), 1, @@ -3247,7 +3247,7 @@ gg_exit(tree exit_code) void gg_abort() { - tree the_call = + tree the_call = build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_ABORT), 0); @@ -3257,7 +3257,7 @@ gg_abort() tree gg_strlen(tree psz) { - tree the_call = fold_convert( + tree the_call = fold_convert( size_type_node, build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_STRLEN), @@ -3283,7 +3283,7 @@ gg_strdup(tree psz) tree gg_malloc(tree size) { - tree the_call = fold_convert( + tree the_call = fold_convert( pvoid_type_node, build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_MALLOC), @@ -3295,7 +3295,7 @@ gg_malloc(tree size) tree gg_realloc(tree base, tree size) { - tree the_call = fold_convert( + tree the_call = fold_convert( pvoid_type_node, build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_REALLOC), @@ -3320,7 +3320,7 @@ gg_malloc(size_t size) void gg_free(tree pointer) { - tree the_call = + tree the_call = build_call_expr_loc(location_from_lineno(), builtin_decl_explicit (BUILT_IN_FREE), 1, @@ -3388,9 +3388,9 @@ tree gg_string_literal(const char *string) { /* This is a message in a bottle. - - A genapi.cc program calling - + + A genapi.cc program calling + gg_call(VOID, "puts", build_string_literal(strlen(ach)+1, ach), @@ -3398,18 +3398,18 @@ gg_string_literal(const char *string) ten thousand times compiles about ten percent slower than a C program calling - + puts(ach); - + ten thousand times. Trapping through the C front end reveals that they do not call build_string_literal(). They instead use build_string() in a way that I gave up trying to figure out that produces, apparently, more efficient GENERIC. - + Their GENERIC: call_expr -> nop_expr -> addr_expr -> string_cst - + My GENERIC: call_expr -> addr_expr -> array_ref -> string_cst I tried for an hour to duplicate the C stuff, but made no headway. @@ -3475,4 +3475,3 @@ gg_insert_into_assembler(const char *format, ...) // And insert it as a statement gg_append_statement(asm_expr); } - diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc index bd224da07a251c06705ba13b141a9eb4cac787b6..b890c43770262bf4c7ec87523154e0a0a9c02f27 100644 --- a/gcc/cobol/genmath.cc +++ b/gcc/cobol/genmath.cc @@ -1722,7 +1722,7 @@ parser_subtract(cbl_refer_t cref, // cref = aref - bref B[0] = bref; parser_subtract(1, C, // Beware: C = A - B, but the order has changed - 1, B, + 1, B, 1, A, giving_e, NULL, diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc index 54f7a0b91e9c47bab575969ccf967c84c09ca55f..4feadb3a9ae892878894320c5943adf5d272ae1e 100644 --- a/gcc/cobol/genutil.cc +++ b/gcc/cobol/genutil.cc @@ -91,18 +91,18 @@ tree var_decl_arithmetic_rounds; // int* __gg__arithmetic_rounds; tree var_decl_fourplet_flags_size; // size_t __gg__fourplet_flags_size; tree var_decl_fourplet_flags; // int* __gg__fourplet_flags; -tree var_decl_treeplet_1f; // cblc_field_pp_type_node , "__gg__treeplet_1f" -tree var_decl_treeplet_1o; // SIZE_T_P , "__gg__treeplet_1o" -tree var_decl_treeplet_1s; // SIZE_T_P , "__gg__treeplet_1s" -tree var_decl_treeplet_2f; // cblc_field_pp_type_node , "__gg__treeplet_2f" -tree var_decl_treeplet_2o; // SIZE_T_P , "__gg__treeplet_2o" -tree var_decl_treeplet_2s; // SIZE_T_P , "__gg__treeplet_2s" -tree var_decl_treeplet_3f; // cblc_field_pp_type_node , "__gg__treeplet_3f" -tree var_decl_treeplet_3o; // SIZE_T_P , "__gg__treeplet_3o" -tree var_decl_treeplet_3s; // SIZE_T_P , "__gg__treeplet_3s" -tree var_decl_treeplet_4f; // cblc_field_pp_type_node , "__gg__treeplet_4f" -tree var_decl_treeplet_4o; // SIZE_T_P , "__gg__treeplet_4o" -tree var_decl_treeplet_4s; // SIZE_T_P , "__gg__treeplet_4s" +tree var_decl_treeplet_1f; // cblc_field_pp_type_node , "__gg__treeplet_1f" +tree var_decl_treeplet_1o; // SIZE_T_P , "__gg__treeplet_1o" +tree var_decl_treeplet_1s; // SIZE_T_P , "__gg__treeplet_1s" +tree var_decl_treeplet_2f; // cblc_field_pp_type_node , "__gg__treeplet_2f" +tree var_decl_treeplet_2o; // SIZE_T_P , "__gg__treeplet_2o" +tree var_decl_treeplet_2s; // SIZE_T_P , "__gg__treeplet_2s" +tree var_decl_treeplet_3f; // cblc_field_pp_type_node , "__gg__treeplet_3f" +tree var_decl_treeplet_3o; // SIZE_T_P , "__gg__treeplet_3o" +tree var_decl_treeplet_3s; // SIZE_T_P , "__gg__treeplet_3s" +tree var_decl_treeplet_4f; // cblc_field_pp_type_node , "__gg__treeplet_4f" +tree var_decl_treeplet_4o; // SIZE_T_P , "__gg__treeplet_4o" +tree var_decl_treeplet_4s; // SIZE_T_P , "__gg__treeplet_4s" // There are times when I need to insert a NOP into the code, mainly to force // a .loc directive into the assembly language so that the GDB-COBOL debugger @@ -252,7 +252,7 @@ get_integer_value(tree value, gg_assign(rdigits, gg_cast(INT, member(field, "rdigits"))); // Scale by the number of rdigits, which turns 12.34 into 12. - // When check_for_fractional_digits is true, __gg__rdigits will be set + // When check_for_fractional_digits is true, __gg__rdigits will be set // to 1 for 12.34, and will be set to zero 12.00 scale_by_power_of_ten(temp, gg_negate(rdigits), @@ -275,7 +275,7 @@ get_data_offset_dest(cbl_refer_t &refer, Analyze(); // This routine returns a tree which is the size_t offset to the data in the // refer/field - + // Because this is for destination/receiving variables, OCCURS DEPENDING ON // is not checked. @@ -321,7 +321,7 @@ get_data_offset_dest(cbl_refer_t &refer, // we might have an error condition at this point: if( !parent ) { - cbl_internal_error("Too many subscripts"); + cbl_internal_error("Too many subscripts"); } // Pick up the integer value of the subscript: static tree subscript = gg_define_variable(LONG, "..gdod_subscript", vs_file_static); @@ -555,7 +555,7 @@ get_data_offset_source(cbl_refer_t &refer, // This routine returns a tree which is the size_t offset to the data in the // refer/field - // Because this is for source / sending variables, checks are made for + // Because this is for source / sending variables, checks are made for // OCCURS DEPENDING ON violations (when those exceptions are enabled) tree retval = gg_define_variable(SIZE_T); @@ -828,7 +828,7 @@ get_data_offset_source(cbl_refer_t &refer, return retval; } -void +void get_binary_value( tree value, tree rdigits, cbl_field_t *field, @@ -877,7 +877,7 @@ get_binary_value( tree value, tree dest_type = TREE_TYPE(value); tree source_type = tree_type_from_field(field); - gg_assign(value, + gg_assign(value, gg_cast(dest_type, gg_indirect( gg_cast(build_pointer_type(source_type), gg_get_address_of(field->data_decl_node))))); @@ -1368,7 +1368,7 @@ get_binary_value( tree value, case FldAlphanumeric: { - + } @@ -1481,7 +1481,7 @@ scale_by_power_of_ten_N(tree value, bool check_for_fractional) { // This routine is called when we know N at compile time. - + Analyze(); Analyzer.Message("takes int N"); if( N == 0 ) @@ -1856,7 +1856,7 @@ copy_little_endian_into_place(cbl_field_t *dest, // lhs is 99.999. So, lhs.digits is 5, and lhs.rdigits is 3. // 10^(5 - 3 + 2) is 10^4, which is 10000. Because 12345 is >= 10000, the // source can't fit into the destination. - + // Note: I am not trying to avoid the use of stack variables, because I am // not sure how to declare a file-static variable of unknown type. tree abs_value = gg_define_variable(TREE_TYPE(value)); @@ -2020,8 +2020,8 @@ build_array_of_size_t( size_t N, const size_t *values) { // We create and populate an array of size_t values - - // This only works because it is used in but one spot. If this routine is + + // This only works because it is used in but one spot. If this routine is // called twice, be careful about how the first one is used. It's a static // variable, you see. static tree values_p = gg_define_variable(SIZE_T_P, "..baost_values_p", vs_file_static); @@ -2141,13 +2141,13 @@ refer_refmod_length(cbl_refer_t &refer) if( any_length ) { - rt_capacity = + rt_capacity = gg_cast(LONG, member(refer.field->var_decl_node, "capacity")); } else { - rt_capacity = + rt_capacity = build_int_cst_type(LONG, refer.field->data.capacity); } @@ -2179,7 +2179,7 @@ refer_refmod_length(cbl_refer_t &refer) } else { - get_integer_value(value64, + get_integer_value(value64, refer.refmod.from->field, refer_offset_source(*refer.refmod.from) ); @@ -2269,9 +2269,9 @@ refer_refmod_length(cbl_refer_t &refer) if( enabled_exceptions.match(ec_bound_ref_mod_e) ) { SET_EXCEPTION_CODE(ec_bound_ref_mod_e); - + // Our intentions are honorable. But at this point, where - // we notice that start + length is too long, the + // we notice that start + length is too long, the // get_data_offset_source routine has already been run and // it's too late to actually change the refstart. There are // theoretical solutions to this -- mainly, @@ -2554,7 +2554,7 @@ refer_offset_source(cbl_refer_t &refer, tree retval = gg_define_variable(SIZE_T); gg_assign(var_decl_odo_violation, integer_zero_node); - + gg_assign(retval, get_data_offset_source(refer, pflags)); if( process_this_exception(ec_bound_odo_e) ) { @@ -2648,5 +2648,3 @@ qualified_data_dest(cbl_refer_t &refer) return gg_add(member(refer.field->var_decl_node, "data"), refer_offset_dest(refer)); } - - diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc index 1e71a9fa85e5baea29c1ff32635244abe79d0347..f5d05ac9432255bad5550d67f0dd9c1e61df45b9 100644 --- a/gcc/cobol/lexio.cc +++ b/gcc/cobol/lexio.cc @@ -131,7 +131,7 @@ static char * remove_inline_comment( char *bol, char *eol ) { static char ends = '\0'; char *nl = std::find(bol, eol, '\n'); - + if( bol < nl ) { std::swap(*nl, ends); char *comment = strstr(bol, "*>"); @@ -265,12 +265,12 @@ recognize_replacements( filespan_t mfile, std::list<replace_t>& pending_replacem if( yy_flex_debug ) { size_t n = count_newlines(mfile.data, found.p); dbgmsg("%s:%d first '%.*s' is on line %zu (offset %zu)", __func__, __LINE__, - directive.before.size(), directive.before.p, - ++n, found.p - mfile.data); + directive.before.size(), directive.before.p, + ++n, found.p - mfile.data); } } else { - dbgmsg("%s:%d not found: '%s' in \n'%.*s'", __func__, __LINE__, - directive.before.p, int(strlen(directive.before.p)), mfile.cur); + dbgmsg("%s:%d not found: '%s' in \n'%.*s'", __func__, __LINE__, + directive.before.p, int(strlen(directive.before.p)), mfile.cur); } futures.push_back( future_replacement_t(directive, found) ); } @@ -295,10 +295,10 @@ recognize_replacements( filespan_t mfile, std::list<replace_t>& pending_replacem if( yy_flex_debug ) { size_t n = std::count((const char *)mfile.data, recognized.before.p, '\n'); dbgmsg( "%s:%d: line %zu @ %zu: '%s'\n/%.*s/%.*s/", __func__, __LINE__, - ++n, next.found.p - mfile.data, - next.directive.before.p, - int(recognized.before.size()), recognized.before.p, - int(recognized.after.size()), recognized.after.p ); + ++n, next.found.p - mfile.data, + next.directive.before.p, + int(recognized.before.size()), recognized.before.p, + int(recognized.after.size()), recognized.after.p ); } // Update the futures element for this pattern @@ -313,8 +313,8 @@ recognize_replacements( filespan_t mfile, std::list<replace_t>& pending_replacem size_t n = std::count((const char *)mfile.data, next.found.p, '\n'); if( false ) dbgmsg("%s:%d next '%.*s' will be on line %zu (offset %zu)", __func__, __LINE__, - next.directive.before.size(), next.directive.before.p, - ++n, next.found.p - mfile.data); + next.directive.before.size(), next.directive.before.p, + ++n, next.found.p - mfile.data); } pnext = std::min_element(futures.begin(), futures.end()); } @@ -349,7 +349,7 @@ check_source_format_directive( filespan_t& mfile ) { } mfile.cur = const_cast<char*>(cm[0].second); dbgmsg( "%s:%d: %s format set, on line %zu", __func__, __LINE__, - indicator.column == 7? "FIXED" : "FREE", mfile.lineno() ); + indicator.column == 7? "FIXED" : "FREE", mfile.lineno() ); erase_line(const_cast<char*>(cm[0].first), const_cast<char*>(cm[0].second)); } @@ -455,7 +455,7 @@ last_newline (const char *p, const char *pend ) { } /* * For some statement parsed with regex_search, set yyloc to indicate the line - * and column spans of the term. Assume stmt begins at the start of a line. + * and column spans of the term. Assume stmt begins at the start of a line. */ static void update_yylloc( const csub_match& stmt, const csub_match& term ) { @@ -465,17 +465,17 @@ update_yylloc( const csub_match& stmt, const csub_match& term ) { public: dump_loc_on_exit() { if( getenv( "update_yylloc" ) ) - location_dump( "update_yylloc", __LINE__, "begin", yylloc); + location_dump( "update_yylloc", __LINE__, "begin", yylloc); } ~dump_loc_on_exit() { if( getenv( "update_yylloc" ) ) - location_dump( "update_yylloc", __LINE__, "end ", yylloc); + location_dump( "update_yylloc", __LINE__, "end ", yylloc); } } dloe; - + size_t nline = std::count( stmt.first, term.second, '\n' ); size_t n = std::count( term.first, term.second, '\n' ); - + if( nline ) { yylloc.last_line += nline; yylloc.first_line = yylloc.last_line - n; @@ -499,9 +499,9 @@ update_yylloc( const csub_match& stmt, const csub_match& term ) { yylloc.last_column = (term.second - p) + 1; return; } - + const char *bol = p; // bol points to last newline before term - + yylloc.first_column = term.first - bol; p = last_newline(term.first, term.second); if( p ) { // term has newlines, too @@ -555,7 +555,7 @@ parse_replacing_term( const char *stmt, const char *estmt ) { output.stmt = cm[0]; gcc_assert(output.stmt.pend[-1] == '.'); dbgmsg("%s:%d: done at '%.*s'", __func__, __LINE__, - output.term.size(), output.term.p); + output.term.size(), output.term.p); return output; } @@ -572,8 +572,8 @@ parse_replacing_term( const char *stmt, const char *estmt ) { if( output.done ) output.stmt.pend++; } dbgmsg("%s:%d: %s '%.*s'", __func__, __LINE__, - output.done? "done at" : "term is", - output.term.size(), output.term.p); + output.done? "done at" : "term is", + output.term.size(), output.term.p); return output; } @@ -592,7 +592,7 @@ parse_replacing_term( const char *stmt, const char *estmt ) { output.matched = output.stmt.p < output.term.p; gcc_assert(output.matched); dbgmsg("%s:%d: term is '%.*s'", __func__, __LINE__, - output.term.size(), output.term.p); + output.term.size(), output.term.p); return output; } @@ -617,7 +617,7 @@ parse_replacing_term( const char *stmt, const char *estmt ) { gcc_assert(0 < output.term.size()); dbgmsg("%s:%d: more words starting at '%.80s'", __func__, __LINE__, - output.term.pend); + output.term.pend); static const char term_pattern[] = "^[[:space:]]+" @@ -673,7 +673,7 @@ parse_replacing_term( const char *stmt, const char *estmt ) { const char *status = "unmatched"; if( output.matched ) status = output.done? "done" : "matched"; dbgmsg("%s:%d: %s term is '%.*s'", __func__, __LINE__, status, - output.term.size(), output.term.p? output.term.p : ""); + output.term.size(), output.term.p? output.term.p : ""); } return output; } @@ -703,17 +703,17 @@ parse_replacing_pair( const char *stmt, const char *estmt ) { pair.stmt.pend = parsed.stmt.pend; pair.replace.after = parsed.term; } else { - dbgmsg("%s:%d: not matched '%.*s'", __func__, __LINE__, - pair.stmt.size(), pair.stmt.p); + dbgmsg("%s:%d: not matched '%.*s'", __func__, __LINE__, + pair.stmt.size(), pair.stmt.p); } } if( yy_flex_debug ) { const char *status = "unmatched"; if( pair.matched() ) status = pair.done()? "done" : "matched"; dbgmsg("%s:%d: [%s] replacing '%.*s' with '%.*s'", __func__, __LINE__, - status, - pair.replace.before.size(), pair.replace.before.p, - pair.replace.after.size(), pair.replace.after.p); + status, + pair.replace.before.size(), pair.replace.before.p, + pair.replace.after.size(), pair.replace.after.p); } } else { for( auto p = stmt; (p = std::find(p, estmt, '.')) < estmt; p++ ) { @@ -770,10 +770,10 @@ parse_replace_pairs( const char *stmt, const char *estmt, bool is_copy_stmt ) { if( false && yy_flex_debug ) { for( size_t i=0; i < cm.size(); i++ ) { dbgmsg("%s: %s %zu: '%.*s'", __func__, - cm[i].matched? "Pair" : "pair", - i, - cm[i].matched? int(cm[i].length()) : 0, - cm[i].matched? cm[i].first : ""); + cm[i].matched? "Pair" : "pair", + i, + cm[i].matched? int(cm[i].length()) : 0, + cm[i].matched? cm[i].first : ""); } } gcc_assert(cm[3].matched); @@ -812,7 +812,7 @@ parse_replace_pairs( const char *stmt, const char *estmt, bool is_copy_stmt ) { gcc_assert(false); } dbgmsg("%s:%d: dealing with %.*s", __func__, __LINE__, - int(parsed.leading_trailing.size()), parsed.leading_trailing.p); + int(parsed.leading_trailing.size()), parsed.leading_trailing.p); } src = xasprintf("%s(%s)%s", befter[0], src, befter[1]); @@ -831,12 +831,12 @@ parse_replace_pairs( const char *stmt, const char *estmt, bool is_copy_stmt ) { if( yy_flex_debug ) { dbgmsg( "%s:%d: %s: %zu pairs parsed from '%.*s'", __func__, __LINE__, - parsed.done()? "done" : "not done", - pairs.size(), parsed.stmt.size(), parsed.stmt.p ); + parsed.done()? "done" : "not done", + pairs.size(), parsed.stmt.size(), parsed.stmt.p ); int i = 0; for( const auto& replace : pairs ) { dbgmsg("%s:%d:%4d: '%s' => '%s'", __func__, __LINE__, - ++i, replace.before.p, replace.after.p); + ++i, replace.before.p, replace.after.p); } } if( !parsed.done() ) { @@ -860,7 +860,7 @@ struct copy_descr_t { static YYLTYPE location_in( const filespan_t& mfile, const csub_match cm ) { YYLTYPE loc { - int(mfile.lineno() + 1), int(mfile.colno() + 1), + int(mfile.lineno() + 1), int(mfile.colno() + 1), int(mfile.lineno() + 1), int(mfile.colno() + 1) }; gcc_assert(mfile.cur <= cm.first && cm.second <= mfile.eodata); @@ -915,8 +915,8 @@ parse_copy_directive( filespan_t& mfile ) { size_t nnl = 1 + count_newlines(mfile.data, copy_stmt.p); size_t nst = 1 + count_newlines(copy_stmt.p, copy_stmt.pend); dbgmsg("%s:%d: line %zu: COPY directive is %zu lines '%.*s'", - __func__, __LINE__, - nnl, nst, copy_stmt.size(), copy_stmt.p); + __func__, __LINE__, + nnl, nst, copy_stmt.size(), copy_stmt.p); } } } @@ -950,7 +950,7 @@ parse_copy_directive( filespan_t& mfile ) { } YYLTYPE loc = location_in( mfile, copybook_name ); outcome.fd = copybook.open( loc, xstrndup(copybook_name.first, - copybook_name.length()) ); + copybook_name.length()) ); if( outcome.fd == -1 ) { // let parser report missing copybook dbgmsg("%s:%d: (no copybook '%s' found)", __func__, __LINE__, copybook.source()); return outcome; @@ -1014,7 +1014,7 @@ parse_replace_last_off( filespan_t& mfile ) { } dbgmsg( "%s:%d: line %zu: parsed '%.*s', ", __func__, __LINE__, - mfile.lineno(), int(cm[0].length()), cm[0].first ); + mfile.lineno(), int(cm[0].length()), cm[0].first ); // Remove statement from input erase_line(const_cast<char*>(cm[0].first), @@ -1052,8 +1052,8 @@ parse_replace_text( filespan_t& mfile ) { if( ! regex_search(mfile.ccur(), (const char *)mfile.eodata, cm, re) ) { dbgmsg( "%s:%d: line %zu: not a REPLACE statement:\n'%.*s'", - __func__, __LINE__, current_lineno, - int(mfile.line_length()), mfile.cur ); + __func__, __LINE__, current_lineno, + int(mfile.line_length()), mfile.cur ); return span_t(); } @@ -1291,7 +1291,7 @@ lexer_input( char buf[], int max_size, FILE *input ) { char *next = std::min(mfile.eodata, mfile.cur + max_size); buffer_t output(buf, buf + max_size); // initializes pos - // Fill output, keeping only NL for blank lines. + // Fill output, keeping only NL for blank lines. for( auto p = mfile.cur; p < next; *output.pos++ = *p++ ) { static bool at_bol = false; if( at_bol ) { @@ -1353,7 +1353,7 @@ static std::list<preprocessor_filter_t> preprocessor_filters; static std::list<const char *> included_files; /* - * Keep a list of files added with -include on the command line. + * Keep a list of files added with -include on the command line. */ bool include_file_add(const char filename[]) { @@ -1372,11 +1372,11 @@ preprocess_filter_add( const char input[] ) { if( optstr ) { for( char *opt = optstr + 1; (opt = strtok(opt, ",")); opt = NULL ) { - options.push_back(opt); + options.push_back(opt); } *optstr = '\0'; } - + auto filename = find_filter(filter); if( !filename ) { yywarn("preprocessor '%s/%s' not found", getcwd(NULL, 0), filter); @@ -1391,7 +1391,7 @@ cdftext::echo_input( int input, const char filename[] ) { int fd; if( -1 == (fd = dup(input)) ) { yywarn( "could not open preprocessed file %s to echo to standard output", - filename ); + filename ); return; } @@ -1425,7 +1425,7 @@ cdftext::lex_open( const char filename[] ) { int output = open_output(); - // Process any files supplied by the -include comamnd-line option. + // Process any files supplied by the -include comamnd-line option. for( auto name : included_files ) { int input; if( -1 == (input = open(name, O_RDONLY)) ) { @@ -1437,7 +1437,7 @@ cdftext::lex_open( const char filename[] ) { process_file( mfile, output ); } - + cobol_filename(filename, inode_of(input)); filespan_t mfile( free_form_reference_format( input ) ); @@ -1461,7 +1461,7 @@ cdftext::lex_open( const char filename[] ) { return xstrdup(opt.c_str()); } ); *last_argv = NULL; - + pid_t pid = fork(); switch(pid){ @@ -1527,8 +1527,8 @@ cdftext::open_output() { if( name && 0 != strcmp(name, "/") ) { char * stem = xasprintf("%sXXXXXX", name); if( -1 == (fd = mkstemp(stem)) ) { - cbl_err( "could not open temporary file '%s' (%s)", - name, realpath(name, stem)); + cbl_err( "could not open temporary file '%s' (%s)", + name, realpath(name, stem)); } return fd; } @@ -1549,12 +1549,12 @@ cdftext::map_file( int fd ) { mfile.use_nada(); struct stat sb; - do { + do { if( 0 != fstat(fd, &sb) ) { cbl_err( "%s: could not stat fd %d", __func__, fd ); } if( S_ISFIFO(sb.st_mode) ) { - // Copy FIFO to regular file that can be mapped. + // Copy FIFO to regular file that can be mapped. int input = open_output(); std::swap(fd, input); // fd will continue to be the input static char block[4096 * 4]; @@ -1565,12 +1565,12 @@ cdftext::map_file( int fd ) { cbl_err( "%s: could not prepare map file from FIFO %d", __func__, input); } - if( false ) dbgmsg("%s: copied %ld bytes from FIFO", + if( false ) dbgmsg("%s: copied %ld bytes from FIFO", __func__, nout); } } } while( S_ISFIFO(sb.st_mode) ); - + if( sb.st_size > 0 ) { static const int flags = MAP_PRIVATE; @@ -1625,7 +1625,7 @@ cdftext::free_form_reference_format( int input ) { if( valid_sequence_area(p, mfile.eodata) ) indicator.column = 7; dbgmsg("%s:%d: %s format detected", __func__, __LINE__, - indicator.column == 7? "FIXED" : "FREE"); + indicator.column == 7? "FIXED" : "FREE"); } while( mfile.next_line() ) { @@ -1699,7 +1699,7 @@ cdftext::free_form_reference_format( int input ) { __attribute__ ((fallthrough)); default: // flag other characters in indicator area if( ! ISSPACE(indcol[0]) ) { - yyerrorvl( mfile.lineno(), cobol_filename(), + yyerrorvl( mfile.lineno(), cobol_filename(), "error: stray indicator '%c' (0x%x): \"%.*s\"", indcol[0], indcol[0], int(mfile.line_length() - 1), mfile.cur ); @@ -1777,8 +1777,8 @@ cdftext::process_file( filespan_t mfile, int output, bool second_pass ) { []( char ch ) { return ch == '\n'; } ); struct { int in, out; filespan_t mfile; } copy; dbgmsg("%s:%d: line %zu, opening %s on fd %d", __func__, __LINE__, - mfile.lineno(), - copybook.source(), copybook.current()->fd); + mfile.lineno(), + copybook.source(), copybook.current()->fd); copy.in = copybook.current()->fd; copy.mfile = free_form_reference_format( copy.in ); @@ -1813,7 +1813,7 @@ cdftext::process_file( filespan_t mfile, int output, bool second_pass ) { continue; // No active REPLACE directive. } - std::list<span_t> segments = segment_line(mfile); // no replace yields + std::list<span_t> segments = segment_line(mfile); // no replace yields // // 1 segment for( const auto& segment : segments ) { @@ -1824,7 +1824,7 @@ cdftext::process_file( filespan_t mfile, int output, bool second_pass ) { struct { size_t before, after; int delta() const { return before - after; } } nlines; - nlines.before = std::count(segments.front().p, + nlines.before = std::count(segments.front().p, segments.front().pend, '\n'); nlines.after = std::count(segments.back().p, segments.back().pend, '\n'); if( nlines.delta() < 0 ) { diff --git a/gcc/cobol/lexio.h b/gcc/cobol/lexio.h index 6c0bd0efcedc3ea980959408c8490150af4f074c..75ee22c0130a415f366ab843bac843412063bf91 100644 --- a/gcc/cobol/lexio.h +++ b/gcc/cobol/lexio.h @@ -125,9 +125,6 @@ struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif -// void location_dump( const char func[], int line, -// const char tag[], const YYLTYPE& loc); - struct filespan_t : public bytespan_t { char *cur, *eol, *quote; private: diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index ef027f94ada40ff5c48d256584314fa3e491acb3..054745941b1817c942c25b34ee3062f77612dc0f 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -47,7 +47,7 @@ accept_command_line_e, accept_envar_e, }; - + class literal_t { size_t isym; public: @@ -200,7 +200,7 @@ {} }; - + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" static data_category_t @@ -272,7 +272,7 @@ typedef struct Elem_list_t<size_t> isym_list_t; struct rel_part_t; - + bool set_debug(bool); #include "ec.h" @@ -342,7 +342,7 @@ %token <number> POSITIVE %token <field_attr> POINTER %token <string> SECTION -%token <number> STANDARD_ALPHABET "STANDARD ALPHABET" +%token <number> STANDARD_ALPHABET "STANDARD ALPHABET" %token <string> SWITCH %token <string> UPSI %token <number> ZERO @@ -363,7 +363,7 @@ TIME_FMT "time format" DATETIME_FMT "datetime format" - /* tokens without semantic value */ + /* tokens without semantic value */ /* CDF (COPY and >> defined here but used in cdf.y) */ %token BASIS CBL CONSTANT COPY DEFINED ENTER FEATURE INSERTT @@ -405,7 +405,7 @@ ASCENDING ACTIVATING ASIN ASSIGN AT ATAN BASED BASECONVERT - BEFORE BINARY BIT BIT_OF "BIT-OF" BIT_TO_CHAR "BIT-TO-CHAR" + BEFORE BINARY BIT BIT_OF "BIT-OF" BIT_TO_CHAR "BIT-TO-CHAR" BLANK BLOCK BOOLEAN_OF_INTEGER "BOOLEAN-OF-INTEGER" BOTTOM BY @@ -449,7 +449,7 @@ EXCEPTION_STATEMENT "EXCEPTION-STATEMENT" EXCEPTION_STATUS "EXCEPTION-STATUS" - FACTORIAL FALSE_kw "False" FD + FACTORIAL FALSE_kw "False" FD FILE_CONTROL "FILE-CONTROL" FILE_KW "File" FILE_LIMIT "FILE-LIMIT" @@ -461,7 +461,7 @@ FORMATTED_DATETIME "FORMATTED-DATETIME" FORMATTED_TIME "FORMATTED-TIME" FORM_OVERFLOW "FORM-OVERFLOW" - FREE + FREE FRACTION_PART "FRACTION-PART" FROM FUNCTION @@ -511,8 +511,8 @@ NATIONAL_EDITED "NATIONAL-EDITED" NATIONAL_OF "NATIONAL-OF" NATIVE NESTED NEXT - NO NOTE - NULLS NULLPTR + NO NOTE + NULLS NULLPTR NUMERIC NUMERIC_EDITED NUMVAL NUMVAL_C "NUMVAL-C" @@ -525,7 +525,7 @@ PACKED_DECIMAL PADDING PAGE PAGE_COUNTER "PAGE-COUNTER" - PF PH PI PIC PICTURE + PF PH PI PIC PICTURE PLUS PRESENT_VALUE PRINT_SWITCH PROCEDURE PROCEDURES PROCEED PROCESS PROGRAM_ID "PROGRAM-ID" @@ -546,7 +546,7 @@ SECURITY SEPARATE SEQUENCE SEQUENTIAL SHARING SIMPLE_EXIT "(simple) EXIT" - SIGN SIN SIZE + SIGN SIN SIZE SMALLEST_ALGEBRAIC "SMALLEST-ALGEBRAIC" SOURCE SOURCE_COMPUTER "SOURCE-COMPUTER" @@ -557,7 +557,7 @@ STANDARD_COMPARE "STANDARD-COMPARE" STATUS STRONG SUBSTITUTE SUM SYMBOL SYMBOLIC SYNCHRONIZED - + TALLY TALLYING TAN TERMINATE TEST TEST_DATE_YYYYMMDD "TEST-DATE-YYYYMMDD" TEST_DAY_YYYYDDD "TEST-DAY-YYYYDDD" @@ -663,7 +663,7 @@ %type <special_type> device_name %type <string> numed collating_sequence context_word ctx_name locale_spec %type <literal> namestr alphabet_lit program_as repo_as -%type <field> perform_cond kind_of_name +%type <field> perform_cond kind_of_name %type <refer> alloc_ret %type <field> log_term rel_expr rel_abbr eval_abbr @@ -675,10 +675,10 @@ %type <field_data> value78 %type <field> literal name nume typename %type <field> num_literal signed_literal - + %type <number> perform_start %type <refer> perform_times -%type <perf> perform_verb +%type <perf> perform_verb perform_inline perform_except %type <refer> eval_subject1 @@ -792,7 +792,7 @@ %type <labels> labels %type <label> label_1 section_name - + %type <switches> upsi_entry %type <special> acceptable disp_target @@ -817,7 +817,7 @@ %type <ec_list> except_names %type <isym_list> except_files %type <dcl_list_t> perform_ec - + %type <opt_init_sects> opt_init_sects %type <opt_init_sect> opt_init_sect %type <number> opt_init_value @@ -863,7 +863,7 @@ struct cbl_perform_tgt_t *tgt; Label_list_t *labels; key_list_t *file_keys; - cbl_file_mode_t io_mode; + cbl_file_mode_t io_mode; struct cbl_file_key_t *file_key; struct file_list_t *files; struct field_list_t *fields; @@ -1011,7 +1011,7 @@ ASCENDING ACTIVATING ASIN ASSIGN AT ATAN BACKWARD BASED BASECONVERT - BEFORE BINARY BIT BIT_OF BIT_TO_CHAR + BEFORE BINARY BIT BIT_OF BIT_TO_CHAR BLANK BLOCK BOOLEAN_OF_INTEGER BOTTOM BY @@ -1051,13 +1051,13 @@ E EBCDIC EC EGCS ENTRY ENVIRONMENT EQUAL ERROR EVERY EXAMINE EXCEPTION EXHIBIT EXP EXP10 EXTEND EXTERNAL - EXCEPTION_FILE - EXCEPTION_FILE_N - EXCEPTION_LOCATION + EXCEPTION_FILE + EXCEPTION_FILE_N + EXCEPTION_LOCATION EXCEPTION_LOCATION_N - EXCEPTION_NAME - EXCEPTION_STATEMENT - EXCEPTION_STATUS + EXCEPTION_NAME + EXCEPTION_STATEMENT + EXCEPTION_STATUS FACTORIAL FALSE_kw FD FILENAME FILE_CONTROL @@ -1071,7 +1071,7 @@ FORMATTED_DATETIME FORMATTED_TIME FORM_OVERFLOW - FREE + FREE FRACTION_PART FROM FUNCTION FUNCTION_UDF @@ -1117,13 +1117,13 @@ MANUAL MAXX MEAN MEDIAN MIDRANGE MIGHT_BE MINN MULTIPLE MOD MODE - MODULE_NAME + MODULE_NAME NAMED NAT NATIONAL NATIONAL_EDITED NATIONAL_OF NATIVE NEGATIVE NESTED NEXT - NINEDOT NINES NINEV NO NOTE NO_CONDITION + NINEDOT NINES NINEV NO NOTE NO_CONDITION NULLS NULLPTR NUMBER NUME NUMED NUMED_CR NUMED_DB NUMERIC NUMERIC_EDITED NUMSTR NUMVAL @@ -1166,12 +1166,12 @@ STANDARD STANDARD_ALPHABET STANDARD_1 - STANDARD_DEVIATION + STANDARD_DEVIATION STANDARD_COMPARE STATUS STRONG STDERR STDIN STDOUT LITERAL SUBSTITUTE SUM SWITCH SYMBOL SYMBOLIC SYNCHRONIZED SYSIN SYSIPT SYSLST SYSOUT SYSPCH SYSPUNCH - + TALLY TALLYING TAN TERMINATE TEST TEST_DATE_YYYYMMDD TEST_DAY_YYYYDDD @@ -1213,13 +1213,13 @@ HIGH_ORDER_LEFT HIGH_ORDER_RIGHT IGNORING IMPLEMENTS INITIALIZED INTERMEDIATE - LC_ALL_kw - LC_COLLATE_kw - LC_CTYPE_kw - LC_MESSAGES_kw - LC_MONETARY_kw - LC_NUMERIC_kw - LC_TIME_kw + LC_ALL_kw + LC_COLLATE_kw + LC_CTYPE_kw + LC_MESSAGES_kw + LC_MONETARY_kw + LC_NUMERIC_kw + LC_TIME_kw LOWLIGHT NEAREST_AWAY_FROM_ZERO NEAREST_EVEN NEAREST_TOWARD_ZERO @@ -1248,7 +1248,7 @@ END_UNSTRING END_WRITE error END_IF - + %left THRU %left OR %left AND @@ -1348,7 +1348,7 @@ cbl_field_t * new_literal( const literal_t& lit, enum cbl_field_attr_t attr ); - + static YYLTYPE first_line_of( YYLTYPE loc ); %} @@ -1512,7 +1512,7 @@ opt_arith: ARITHMETIC is opt_arith_type { } } ; -opt_arith_type: NATIVE { $$ = cbl_options_t::native_e; } +opt_arith_type: NATIVE { $$ = cbl_options_t::native_e; } | STANDARD { $$ = cbl_options_t::standard_e; } | STANDARD_BINARY { $$ = cbl_options_t::standard_binary_e; } | STANDARD_DECIMAL { $$ = cbl_options_t::standard_decimal_e; } @@ -1629,10 +1629,10 @@ opt_init_value: BINARY ZERO { $$ = constant_index(NULLS); } { if( $1.prefix[0] != 'X' ) { error_msg(@1, "hexadecimal literal required"); - } + } if( $1.len != 1 ) { error_msg(@1, "1-byte hexadecimal literal required"); - } + } char ach[16]; sprintf(ach, "%d", (int)($1.data[0])); //auto f = new_literal($1.data); @@ -1862,7 +1862,7 @@ selected_name: external scalar { $$ = $2; } uint32_t len = $name.len; cbl_field_t field = { 0, FldLiteralA, FldInvalid, quoted_e | constant_e, - 0, 0, 0, nonarray, 0, "", 0, cbl_field_t::linkage_t(), + 0, 0, 0, nonarray, 0, "", 0, cbl_field_t::linkage_t(), {len,len,0,0, $name.data, NULL, {NULL}, {NULL}}, NULL }; field.attr |= literal_attr($name.prefix); $$ = new cbl_refer_t( field_add(@name, &field) ); @@ -2073,7 +2073,7 @@ assign_clause: ASSIGN to selected_name[selected] { $$.clause = assign_clause_e; $$.file = new cbl_file_t(protofile); $$.file->filename = field_index($name); - } + } ; collate_clause: collate_claus1 { @@ -2462,7 +2462,7 @@ dev_mnemonic: device_name is NAME { "ARGUMENT-NUMBER", ARG_NUM_e }, { "ARGUMENT-VALUE", ARG_VALUE_e } , { "ENVIRONMENT-NAME", ENV_NAME_e }, - { "ENVIRONMENT-VALUE", ENV_VALUE_e }, + { "ENVIRONMENT-VALUE", ENV_VALUE_e }, }; char device[ 1 + strlen($device) ]; std::transform($device, $device + strlen($device) + 1, @@ -3168,7 +3168,7 @@ occurs_clause: OCCURS cardinal_lb indexed YYERROR; } cbl_occurs_t *occurs = ¤t_field()->occurs; - occurs->bounds.lower = + occurs->bounds.lower = occurs->bounds.upper = $name->data.value; } ; @@ -3438,7 +3438,7 @@ data_descr1: level_name } } - | LEVEL88 NAME /* VALUE */ NULLPTR + | LEVEL88 NAME /* VALUE */ NULLPTR { struct cbl_field_t field = { 0, FldClass, FldInvalid, 0, 0, 0, 88, nonarray, yylineno, "", @@ -3656,7 +3656,7 @@ data_descr1: level_name $field->data.digits); if( $field->attr & separate_e ) { - // This is a gentle kludge required by the the belated + // This is a gentle kludge required by the the belated // introduction of COMP-6, which is like COMP-3 but with no // sign nybble. The code in type_capacity assumes a sign // nybble. @@ -3680,7 +3680,7 @@ data_descr1: level_name $field->type != FldFloat ) { switch( $field->data.initial[0] ) { - case '-': + case '-': if( !$field->has_attr(signable_e) ) { error_msg(@field, "%s is unsigned but has signed VALUE '%s'", $field->name, $field->data.initial); @@ -3826,7 +3826,7 @@ data_clauses: data_clause if( redefined && redefined->type == FldPointer ) { if( yydebug ) { yywarn("expanding %s size from %u bytes to %zu " - "because it redefines %s with USAGE POINTER", + "because it redefines %s with USAGE POINTER", field->name, field->size(), sizeof(void*), redefined->name); } @@ -3834,7 +3834,7 @@ data_clauses: data_clause } } } - + switch( field->type ) { case FldFloat: if( ($$ & picture_clause_e) == picture_clause_e ) { @@ -3988,7 +3988,7 @@ picture_clause: PIC signed nps[fore] nines nps[aft] dialect_mf() ) { // PIC X COMP-X or COMP-9 if( ! field->has_attr(all_x_e) ) { - error_msg(@2, "COMP PICTURE requires all X's or all 9's"); + error_msg(@2, "COMP PICTURE requires all X's or all 9's"); YYERROR; } } else { @@ -4076,7 +4076,7 @@ alphanum_pic: alphanum_part { dbgmsg("%s has %s against %s", field->name, field_attr_str(field), cbl_field_attr_str($2.attr)); - + if( ! field->has_attr($2.attr) ) { field->clear_attr(all_ax_e); // clears 2 bits } @@ -4141,7 +4141,7 @@ count: %empty { $$ = 0; } auto e = symbol_field(PROGRAM, 0, $NAME); if( e ) { // verify not floating point with nonzero fraction auto field = cbl_field_of(e); - assert(is_literal(field)); + assert(is_literal(field)); if( field->data.value != size_t(field->data.value) ) { nmsg++; error_msg(@NAME, "invalid PICTURE count '(%s)'", @@ -4182,27 +4182,27 @@ usage_clause1: usage COMPUTATIONAL[comp] native __attribute__((fallthrough)); case FldNumericBin5: // If no capacity yet, then no picture, infer $comp.capacity. - // If field has capacity, ensure USAGE is compatible. + // If field has capacity, ensure USAGE is compatible. if( field->data.capacity > 0 ) { // PICTURE before USAGE infer = false; - switch( field->type ) { + switch( field->type ) { case FldAlphanumeric: // PIC X COMP-5 or COMP-X - assert( field->data.digits == 0 ); - assert( field->data.rdigits == 0 ); + assert( field->data.digits == 0 ); + assert( field->data.rdigits == 0 ); if( dialect_mf() ) { field->type = $comp.type; - field->clear_attr(signable_e); + field->clear_attr(signable_e); } else { - error_msg(@comp, "numeric USAGE invalid " + error_msg(@comp, "numeric USAGE invalid " "with Alpnanumeric PICTURE"); - YYERROR; + YYERROR; } break; case FldNumericDisplay: // PIC 9 COMP-5 or COMP-X if( $comp.capacity == 0xFF ) { // comp-x is a bit like comp-5 assert( field->data.digits == field->data.capacity ); if( ! dialect_mf() ) { - dialect_error(@1, "COMP-X", "mf"); + dialect_error(@1, "COMP-X", "mf"); } } field->type = $comp.type; @@ -4218,7 +4218,7 @@ usage_clause1: usage COMPUTATIONAL[comp] native field->attr |= separate_e; if( ! dialect_mf() ) { dialect_error(@1, "COMP-6", "mf"); - } + } if( field->type == FldNumericDisplay ) {// PICTURE before USAGE infer = false; assert(field->data.capacity > 0); @@ -4262,9 +4262,9 @@ usage_clause1: usage COMPUTATIONAL[comp] native field->clear_attr(signable_e); if( field->type == FldNumericDisplay ) {// PICTURE before USAGE assert(field->data.capacity > 0); - field->data.capacity = type_capacity(FldPacked, + field->data.capacity = type_capacity(FldPacked, field->data.digits); - } + } $$ = field->type = FldPacked; } | usage INDEX { @@ -4422,7 +4422,7 @@ redefines_clause: REDEFINES NAME[orig] auto f = cbl_field_of(&elem); return f->level == level && - f->parent != parent; + f->parent != parent; } return false; } ); @@ -4431,7 +4431,7 @@ redefines_clause: REDEFINES NAME[orig] error_msg(@2, "cannot redefine %s %s as %s %s " "because %s %s intervenes", orig->level_str(), name_of(orig), - field->level_str(), name_of(field), + field->level_str(), name_of(field), mid->level_str(), name_of(mid)); } @@ -4501,7 +4501,7 @@ same_clause: SAME AS name if( field->level == 77 and !is_elementary(other->type) ) { // ISO 2023 13.18.49.2,P8 error_msg(@name, "%s %s SAME AS %s: must be elementary", - field->level_str(), field->name, other->name); + field->level_str(), field->name, other->name); YYERROR; } @@ -4559,19 +4559,19 @@ sign_separate: %empty { $$ = false; } * by type-name-1 had been coded in place of the TYPE clause, excluding the * level-number, name, alignment, and the GLOBAL, SELECT WHEN, and TYPEDEF * clauses specified for type-name-1;" - * + * * The essential characteristics of a type, which is identified by its - * type-name, are the: - * — relative positions and lengths of the elementary items + * type-name, are the: + * — relative positions and lengths of the elementary items * — ALIGNED clause * — BLANK WHEN ZERO clause * — JUSTIFIED clause * — PICTURE clause * — SIGN clause * — SYNCHRONIZED clause - * — USAGE clause + * — USAGE clause */ -type_clause: TYPE to typename +type_clause: TYPE to typename { cbl_field_t *field = current_field(); if( $typename ) { @@ -4579,7 +4579,7 @@ type_clause: TYPE to typename symbol_field_location( symbol_index(e), @typename ); } } - | USAGE is typename + | USAGE is typename { if( ! dialect_mf() ) { dialect_error(@typename, "USAGE TYPENAME", "mf"); @@ -4593,7 +4593,7 @@ type_clause: TYPE to typename } ; -typedef_clause: is TYPEDEF strong +typedef_clause: is TYPEDEF strong { cbl_field_t *field = current_field(); switch( field->level ) { @@ -4717,14 +4717,14 @@ declaratives: %empty enabled_exceptions = current.enabled_exception_cache; current.enabled_exception_cache.clear(); ast_enter_section(implicit_section()); - } + } ; sentences: sentence { ast_first_statement(@1); symbol_temporaries_free(); } - | section_name + | section_name | paragraph_name[para] '.' { location_set(@para); @@ -4738,7 +4738,7 @@ sentences: sentence { } | sentences sentence { // sentences might not be sentence - ast_first_statement(@2); + ast_first_statement(@2); symbol_temporaries_free(); } | sentences section_name @@ -4879,7 +4879,7 @@ accept: accept_body end_accept { if( $1.from->field == NULL ) { // take next command-line arg parser_accept_command_line(*$1.into, argi, NULL, NULL); cbl_num_result_t tgt { truncation_e, argi }; - parser_add2(tgt, literally_one); // increment argi + parser_add2(tgt, literally_one); // increment argi } else if( $1.from->field == argi ) { parser_move(*$1.into, *$1.from); } else { @@ -4900,10 +4900,10 @@ accept: accept_body end_accept { break; case accept_command_line_e: if( $1.from->field == NULL ) { // take next command-line arg - parser_accept_command_line(*$1.into, argi, + parser_accept_command_line(*$1.into, argi, $ec.on_error, $ec.not_error); cbl_num_result_t tgt { truncation_e, argi }; - parser_add2(tgt, literally_one); // increment argi + parser_add2(tgt, literally_one); // increment argi } else if( $1.from->field == argi ) { parser_move(*$1.into, *$1.from); if( $ec.on_error || $ec.not_error ) { @@ -5330,7 +5330,7 @@ compute_expr: '=' { $$ = $expr; } ; - | EQUAL { + | EQUAL { if( ! dialect_ibm() ) { dialect_error(@1, "EQUAL invalid as assignment operator", "ibm"); } @@ -5526,7 +5526,7 @@ end_program: end_program1[end] '.' // pointer still valid because name is in symbol table ast_end_program(prog->name); } - | end_program1[end] error + | end_program1[end] error { const char *token_name = "???"; switch($end.token) { @@ -5553,7 +5553,7 @@ end_program1: END_PROGRAM namestr[name] $$.token = END_FUNCTION; $$.name = $name; } - | END_PROGRAM '.' // error + | END_PROGRAM '.' // error { $$.token = END_PROGRAM; } @@ -5566,7 +5566,7 @@ end_program1: END_PROGRAM namestr[name] continue_stmt: CONTINUE { statement_begin(@1, CONTINUE); parser_sleep(*cbl_refer_t::empty()); - } + } | CONTINUE AFTER expr SECONDS { statement_begin(@1, CONTINUE); parser_sleep(*$expr); @@ -5591,7 +5591,7 @@ exit: GOBACK exit_with[status] ; /* Valid "simple" EXIT (Format 1) swallowed by lexer */ - /* + /* * If the EXIT PROGRAM statement is executed in a program that * is not under the control of a calling runtime element, the * EXIT PROGRAM statement is treated as if it were a CONTINUE @@ -5636,8 +5636,8 @@ exit_with: %empty ; exit_what: PROGRAM_kw { parser_exit_program(); } | PROGRAM_kw exit_raising[ec] { parser_exit_program(); } - | SECTION { parser_exit_section(); } - | PARAGRAPH { parser_exit_paragraph(); } + | SECTION { parser_exit_section(); } + | PARAGRAPH { parser_exit_paragraph(); } | PERFORM { if( performs.empty() ) { error_msg(@$, "EXIT PERFORM valid only " @@ -5770,26 +5770,26 @@ bool_expr: log_expr { $$ = new_reference($1->resolve()); } ; log_expr: log_term { $$ = new log_expr_t($1); } %prec AND - | log_expr[lhs] OR rel_abbr[rhs] + | log_expr[lhs] OR rel_abbr[rhs] { $$ = $1; $$->or_term($rhs); } - | log_expr[lhs] OR log_expr[rhs] + | log_expr[lhs] OR log_expr[rhs] { $$ = $lhs; - assert( ! $rhs->unresolved() ); // what to do? + assert( ! $rhs->unresolved() ); // what to do? $$->or_term($rhs->and_term()); } - | log_expr[lhs] AND rel_abbr[rhs] + | log_expr[lhs] AND rel_abbr[rhs] { $$ = $1; $$->and_term($rhs); } - | log_expr[lhs] AND log_expr[rhs] + | log_expr[lhs] AND log_expr[rhs] { $$ = $lhs; - assert( ! $rhs->unresolved() ); // what to do? + assert( ! $rhs->unresolved() ); // what to do? $$->and_term($rhs->and_term()); } ; @@ -5816,10 +5816,10 @@ log_term: '(' log_expr ')' { ; rel_expr: rel_lhs rel_term[rhs] - { + { rel_part_t& ante = current.antecedent(); if( $rhs.invert ) { - error_msg(@rhs, "NOT %s is invalid, cannot negate RHS", + error_msg(@rhs, "NOT %s is invalid, cannot negate RHS", ante.operand->field->name); } auto op = ante.relop; @@ -5832,11 +5832,11 @@ rel_expr: rel_lhs rel_term[rhs] $$ = cond; } | rel_lhs[lhs] '(' rel_abbrs ')' { - $$ = $rel_abbrs->resolve(); + $$ = $rel_abbrs->resolve(); } ; -rel_abbrs: rel_abbr { $$ = new log_expr_t($1); } +rel_abbrs: rel_abbr { $$ = new log_expr_t($1); } | '(' rel_abbrs ')' { $$ = $2; $$->resolve(); @@ -5868,7 +5868,7 @@ rel_lhs: rel_term[lhs] relop { } ; -rel_abbr: rel_term { +rel_abbr: rel_term { static rel_part_t ante; ante = current.antecedent(); if( ! ante.operand ) { @@ -5883,11 +5883,11 @@ rel_abbr: rel_term { parser_relop(cond, *ante.operand, ante.relop, *$rel_term.term); $$ = cond; } - | relop rel_term { + | relop rel_term { static rel_part_t ante; if( $rel_term.invert ) { - error_msg(@2, "%s NOT %s is invalid", - keyword_str($relop), + error_msg(@2, "%s NOT %s is invalid", + keyword_str($relop), name_of($rel_term.term->field)); } auto op( relop_of($relop) ); @@ -5904,10 +5904,10 @@ rel_abbr: rel_term { } ; -rel_term: rel_term1 +rel_term: rel_term1 ; -rel_term1: all LITERAL +rel_term1: all LITERAL { $$.invert = false; $$.term = new_reference(new_literal($2, quoted_e)); @@ -6110,7 +6110,7 @@ eval_obj_cols: eval_obj_col | eval_obj_cols ALSO eval_obj_col ; -eval_obj_col: ANY { +eval_obj_col: ANY { auto& ev( eval_stack.current() ); if( ! ev.decide(ANY) ) { error_msg(@1, "WHEN 'ANY' phrase exceeds subject set count of %zu", @@ -6118,7 +6118,7 @@ eval_obj_col: ANY { YYERROR; } } - | true_false { + | true_false { auto& ev( eval_stack.current() ); auto subj( ev.subject() ); if( !subj ) { @@ -6130,7 +6130,7 @@ eval_obj_col: ANY { error_msg(@1, "subject %s, type %s, " "cannot be compared to TRUE/FALSE", subj->name, 3 + cbl_field_type_str(subj->type) ); - } + } ev.decide($1); } | eval_posneg[op] { @@ -6145,7 +6145,7 @@ eval_obj_col: ANY { } ev.decide(op, zero, false); } - | bool_expr { + | bool_expr { auto& ev( eval_stack.current() ); auto subj( ev.subject() ); if( !subj ) { @@ -6158,14 +6158,14 @@ eval_obj_col: ANY { error_msg(@1, "subject %s, type %s, " "cannot be compared to conditional expression", subj->name, 3 + cbl_field_type_str(subj->type) ); - } + } ev.decide(*$1, false); } | eval_abbrs { auto& ev( eval_stack.current() ); ev.decided( $1->resolve() ); } - | rel_term[a] THRU rel_term[b] %prec THRU { + | rel_term[a] THRU rel_term[b] %prec THRU { auto& ev( eval_stack.current() ); auto subj( ev.subject() ); if( !subj ) { @@ -6178,7 +6178,7 @@ eval_obj_col: ANY { error_msg(@a, "THRU with boolean operand"); } if( $b.invert ) { - error_msg(@b, "NOT %s is invalid with THRU", + error_msg(@b, "NOT %s is invalid with THRU", name_of($b.term->field)); } ev.decide(*$a.term, *$b.term, $a.invert); @@ -6205,9 +6205,9 @@ eval_abbrs: rel_term[a] { if( ! ev.compatible($a.term->field) ) { auto obj($a.term->field); error_msg(@1, "subject %s, type %s, " - "cannot be compared %s, type %s", - subj->name, 3 + cbl_field_type_str(subj->type), - obj->name, 3 + cbl_field_type_str(obj->type) ); + "cannot be compared %s, type %s", + subj->name, 3 + cbl_field_type_str(subj->type), + obj->name, 3 + cbl_field_type_str(obj->type) ); } auto result = ev.compare(*$a.term); if( ! result ) YYERROR; @@ -6230,18 +6230,18 @@ eval_abbrs: rel_term[a] { if( ! ev.compatible($a.term->field) ) { auto obj($a.term->field); error_msg(@1, "subject %s, type %s, " - "cannot be compared %s, type %s", - subj->name, 3 + cbl_field_type_str(subj->type), - obj->name, 3 + cbl_field_type_str(obj->type) ); - } + "cannot be compared %s, type %s", + subj->name, 3 + cbl_field_type_str(subj->type), + obj->name, 3 + cbl_field_type_str(obj->type) ); + } if( is_conditional(ev.subject()) ) { auto obj($a.term->field); error_msg(@1, "subject %s, type %s, " - "cannot be %s %s, type %s", - subj->name, 3 + cbl_field_type_str(subj->type), - relop_str(relop_of($relop)), - obj->name, 3 + cbl_field_type_str(obj->type) ); - } + "cannot be %s %s, type %s", + subj->name, 3 + cbl_field_type_str(subj->type), + relop_str(relop_of($relop)), + obj->name, 3 + cbl_field_type_str(obj->type) ); + } auto result = ev.compare(relop, *$a.term); if( ! result ) YYERROR; if( $a.invert ) { @@ -6301,7 +6301,7 @@ true_false: TRUE_kw { $$ = TRUE_kw; } ; scalar: tableref { - // Check for missing subscript; others already checked. + // Check for missing subscript; others already checked. if( $1->nsubscript == 0 && 0 < dimensions($1->field) ) { subscript_dimension_error(@1, 0, $$); } @@ -6350,14 +6350,14 @@ tableish: name subscripts[subs] refmod[ref] %prec NAME refmod: LPAREN expr[from] ':' expr[len] ')' %prec NAME { - if( ! require_numeric(@from, *$from) ) YYERROR; - if( ! require_numeric(@len, *$len) ) YYERROR; + if( ! require_numeric(@from, *$from) ) YYERROR; + if( ! require_numeric(@len, *$len) ) YYERROR; $$.from = $from; $$.len = $len; } | LPAREN expr[from] ':' ')' %prec NAME { - if( ! require_numeric(@from, *$from) ) YYERROR; + if( ! require_numeric(@from, *$from) ) YYERROR; $$.from = $from; $$.len = nullptr; } @@ -6382,7 +6382,7 @@ name: qname auto inner = namelocs.back(); if( ($$ = field_find(names)) == NULL ) { if( procedure_div_e == current_division ) { - error_msg(inner.loc, + error_msg(inner.loc, "DATA-ITEM '%s' not found", inner.name ); YYERROR; } @@ -6668,7 +6668,7 @@ move_tgts: move_tgt[tgt] { if( $tgt ) list_add($1->targets, *$tgt, current_rounded_mode()); } ; -move_tgt: scalar[tgt] { +move_tgt: scalar[tgt] { if( is_literal($tgt->field) ) { auto litcon = $tgt->field->name[0] == '_'? "literal" : "constant"; error_msg(@1, "%s is a %s", name_of($tgt->field), litcon); @@ -6690,7 +6690,7 @@ move_tgt: scalar[tgt] { { static const char * error_at; if( error_at != yytext ) { // avoid repeated message - error_at = yytext; + error_at = yytext; error_msg(first_line_of(@1), "invalid receiving operand"); } $$ = NULL; @@ -6871,7 +6871,7 @@ num_value: scalar // might actually be a string dialect_error(@1, "LENGTH OF", "ibm"); } if( 0 == dimensions($val) ) { - cbl_refer_t r1($val); + cbl_refer_t r1($val); subscript_dimension_error( @subs, $subs->refers.size(), &r1 ); } parser_set_numeric($$->field, $val->data.capacity); @@ -7013,7 +7013,7 @@ subscripts: LPAREN expr_list ')' { for( auto refer : exprs ) { if( ! is_numeric(refer.field) ) { error_msg(@1, "subscript %d, %s, is not numeric (%s)", - ++i, name_of(refer.field), + ++i, name_of(refer.field), cbl_field_type_str(refer.field->type) + 3); } } @@ -7023,7 +7023,7 @@ subscripts: LPAREN expr_list ')' { ; expr_list: expr { - if( ! require_numeric(@expr, *$expr) ) YYERROR; + if( ! require_numeric(@expr, *$expr) ) YYERROR; $$ = new refer_list_t($expr); } | expr_list expr { @@ -7032,7 +7032,7 @@ expr_list: expr MAXIMUM_TABLE_DIMENSIONS); YYERROR; } - if( ! require_numeric(@expr, *$expr) ) YYERROR; + if( ! require_numeric(@expr, *$expr) ) YYERROR; $1->push_back($2); $$ = $1; } | ALL { @@ -7077,7 +7077,7 @@ signed_literal: num_literal dialect_error(@1, "LENGTH OF", "ibm"); } if( 0 == dimensions($val) ) { - cbl_refer_t r1($val); + cbl_refer_t r1($val); subscript_dimension_error( @subs, $subs->refers.size(), &r1 ); } parser_set_numeric($$, $val->data.capacity); @@ -7353,11 +7353,11 @@ perform_except: perform_start auto lave = perf->ec_labels.new_label(LblParagraph, "lave"); auto handlers = cbl_field_of(symbol_at(iblob)); - // install blob + // install blob parser_label_label(perf->ec_labels.init); declarative_runtime_match(handlers, lave); - // uninstall blob + // uninstall blob parser_label_label(perf->ec_labels.fini); } ; @@ -7401,7 +7401,7 @@ perform_ec: EXCEPTION filenames { auto dcl = new cbl_declarative_t(0, ec_io_e, files, file_mode_none_e); dcls->elems.push_back(dcl); - } + } $$ = dcls; } | EXCEPTION io_mode { @@ -7416,7 +7416,7 @@ perform_ec: EXCEPTION filenames { std::back_inserter(dcls->elems), []( ec_type_t ec ) { - return new cbl_declarative_t(ec); + return new cbl_declarative_t(ec); } ); $$ = dcls; } @@ -7437,7 +7437,7 @@ perform_ec: EXCEPTION filenames { } ; -except_names: except_name { $$ = new ec_list_t($1); } +except_names: except_name { $$ = new ec_list_t($1); } | except_names except_name { $$ = $1->push_back($2); } @@ -7457,7 +7457,7 @@ except_files: except_name[ec] FILE_KW filenames { $$ = new isym_list_t; std::list<size_t>& files( $$->elems ); std::transform( $filenames->files.begin(), - $filenames->files.end(), + $filenames->files.end(), std::back_inserter(files), []( const cbl_file_t* f ) { return symbol_index(symbol_elem_of(f)); } ); @@ -7653,7 +7653,7 @@ varg1a: ADDRESS OF scalar { dialect_error(@1, "LENGTH OF", "ibm"); } if( 0 == dimensions($val) ) { - cbl_refer_t r1($val); + cbl_refer_t r1($val); subscript_dimension_error( @subs, $subs->refers.size(), &r1 ); } parser_set_numeric($$->field, $val->data.capacity); @@ -8606,7 +8606,7 @@ sort_table: SORT tableref[table] sort_keys sort_dup sort_seq { cbl_key_t keys[nkey], *pkey = keys; if( ! is_table($table->field) ) { error_msg(@1, "%s has no OCCURS clause", $table->field->name); - } + } // 23) If data-name-1 is omitted, the data item referenced by // data-name-2 is the key data item. for( auto k : $sort_keys->key_list ) { @@ -8622,7 +8622,7 @@ sort_table: SORT tableref[table] sort_keys sort_dup sort_seq { statement_begin(@1, SORT); if( ! is_table($table->field) ) { error_msg(@1, "%s has no OCCURS clause", $table->field->name); - } + } cbl_key_t key = cbl_key_t($table->field->occurs.keys[0]), guess(1, &$table->field); @@ -8919,7 +8919,7 @@ inspect: INSPECT backward inspected TALLYING tallies statement_begin(@1, INSPECT); // IBM Format 4 does not show the qualifiers as optional, but // they don't appear in Listing-15-1. - parser_inspect_conv( *$inspected, $backward, + parser_inspect_conv( *$inspected, $backward, *$match, *$replace_oper, $qual->before, $qual->after ); @@ -9138,7 +9138,7 @@ insp_qual: befter initial alpha_val first_leading: FIRST { $$ = bound_first_e; } | ALL { $$ = bound_all_e; } | LEADING { $$ = bound_leading_e; } - | TRAILING { $$ = bound_trailing_e; + | TRAILING { $$ = bound_trailing_e; if( ! dialect_mf() ) { dialect_error(@1, "TRAILING", "mf"); } @@ -9920,7 +9920,7 @@ function_udf: FUNCTION_UDF '(' arg_list[args] ')' { auto narg = $args->refers.size(); cbl_ffi_arg_t args[narg]; size_t i = 0; - // Pass parameters as defined by the function. + // Pass parameters as defined by the function. std::transform( $args->refers.begin(), $args->refers.end(), args, [params, &i]( cbl_refer_t& arg ) { function_descr_arg_t param = params.at(i++); @@ -10499,10 +10499,10 @@ intrinsic: function_udf ; module_type: ACTIVATING { $$ = module_activating_e; } - | CURRENT { $$ = module_current_e; } - | NESTED { $$ = module_nested_e; } - | STACK { $$ = module_stack_e; } - | TOP_LEVEL { $$ = module_toplevel_e; } + | CURRENT { $$ = module_current_e; } + | NESTED { $$ = module_nested_e; } + | STACK { $$ = module_stack_e; } + | TOP_LEVEL { $$ = module_toplevel_e; } ; convert_src: ANY @@ -10515,9 +10515,9 @@ convert_dst: convert_fmt HEX convert_fmt: ALPHANUMERIC | ANUM | NAT - | NATIONAL + | NATIONAL ; - + numval_locale: %empty { $$.is_locale = false; $$.arg2 = cbl_refer_t::empty(); @@ -10678,7 +10678,7 @@ intrinsic_I: BOOLEAN_OF_INTEGER { $$ = BOOLEAN_OF_INTEGER; | FRACTION_PART { $$ = FRACTION_PART; } | HIGHEST_ALGEBRAIC { $$ = HIGHEST_ALGEBRAIC; } | INTEGER { $$ = INTEGER; } - | INTEGER_OF_BOOLEAN { $$ = INTEGER_OF_BOOLEAN; + | INTEGER_OF_BOOLEAN { $$ = INTEGER_OF_BOOLEAN; cbl_unimplemented("INTEGER-OF-BOOLEAN"); } | INTEGER_OF_DATE { $$ = INTEGER_OF_DATE; } @@ -10708,7 +10708,7 @@ intrinsic_N: ABS { $$ = ABS; } | LOG { $$ = LOG; } | LOG10 { $$ = LOG10; } | SIN { $$ = SIN; } - | SMALLEST_ALGEBRAIC { $$ = SMALLEST_ALGEBRAIC; + | SMALLEST_ALGEBRAIC { $$ = SMALLEST_ALGEBRAIC; cbl_unimplemented("SMALLEST-ALGEBRAIC"); } | SQRT { $$ = SQRT; } @@ -10865,7 +10865,7 @@ sign: %empty | SIGN ; -start_after: %empty %prec AFTER +start_after: %empty %prec AFTER | START AFTER varg ; @@ -10937,7 +10937,7 @@ cdf_use: USE DEBUGGING on labels } | USE globally mistake procedure on filenames - { + { if( ! current.declarative_section_name() ) { error_msg(@1, "USE valid only in DECLARATIVES"); YYERROR; @@ -11009,7 +11009,7 @@ cdf_use_files: %empty { $$ = NULL; } | FILE_KW filenames { $$ = $2; } ; -io_mode: INPUT { $$ = file_mode_input_e; } +io_mode: INPUT { $$ = file_mode_input_e; } | OUTPUT { $$ = file_mode_output_e; } | IO { $$ = file_mode_io_e; } | EXTEND { $$ = file_mode_extend_e; } @@ -11107,10 +11107,10 @@ statement_begin( const YYLTYPE& loc, int token ) { // parser_print_string("statement_begin()\n"); location_set(loc); prior_statement = token; - + parser_statement_begin(); - if( token != CONTINUE ) { + if( token != CONTINUE ) { if( enabled_exceptions.size() ) { current.declaratives_evaluate(ec_none_e); cbl_enabled_exceptions_array_t enabled(enabled_exceptions); @@ -11163,9 +11163,9 @@ tokenset_t::tokenset_t() { int tokenset_t::find( const cbl_name_t name, bool include_intrinsics ) { static const cbl_name_t non_names[] = { // including CDF NAMES, and "SWITCH" - "CHECKING", "LIST", "LOCATION", "MAP", "SWITCH", + "CHECKING", "LIST", "LOCATION", "MAP", "SWITCH", }, * const eonames = non_names + COUNT_OF(non_names); - + if( std::any_of(non_names, eonames, [candidate=name](const cbl_name_t non_name) { return 0 == strcasecmp(non_name, candidate) @@ -11173,12 +11173,12 @@ tokenset_t::find( const cbl_name_t name, bool include_intrinsics ) { } ) ) { return 0; // CDF names are never ordinary tokens } - + if( dialect_ibm() ) { - static const cbl_name_t ibm_non_names[] = { - "RESUME", + static const cbl_name_t ibm_non_names[] = { + "RESUME", }, * const eonames = ibm_non_names + COUNT_OF(ibm_non_names); - + if( std::any_of(ibm_non_names, eonames, [candidate=name](const cbl_name_t non_name) { return 0 == strcasecmp(non_name, candidate) @@ -11187,7 +11187,7 @@ tokenset_t::find( const cbl_name_t name, bool include_intrinsics ) { return 0; // Names not reserved by IBM are never ordinary IBM tokens } } - + cbl_name_t lname; std::transform(name, name + strlen(name) + 1, lname, tolower); auto p = tokens.find(lname); @@ -11195,16 +11195,16 @@ tokenset_t::find( const cbl_name_t name, bool include_intrinsics ) { int token = p->second; if( token == SECTION ) yylval.number = 0; - + if( include_intrinsics ) return token; - + return intrinsic_cname(token)? 0 : token; } int keyword_tok( const char * text, bool include_intrinsics ) { - return tokens.find(text, include_intrinsics); -} + return tokens.find(text, include_intrinsics); +} static inline size_t verify_figconst( enum cbl_figconst_t figconst , size_t pos ) { @@ -11418,7 +11418,7 @@ label_add( const YYLTYPE& loc, /* * Many label names are defined statically and so are guaranteed to be in * bounds. Often they are created far away from the yacc metavariables, so - * there's no location to access. + * there's no location to access. */ static struct cbl_label_t * label_add( enum cbl_label_type_t type, const char name[], int line ) { @@ -11598,13 +11598,13 @@ current_t::udf_args_valid( const cbl_label_t *L, assert(func != udfs.end()); function_descr_t udf = *func; params = udf.linkage_fields; - + if( udf.linkage_fields.size() < args.size() ) { auto loc = symbol_field_location(field_index(args.back().field)); error_msg(loc, "too many parameters for UDF %s", L->name); return false; } - + size_t i = 0; for( cbl_refer_t arg : args ) { if( arg.field ) { // else omitted @@ -12050,10 +12050,10 @@ data_category_of( const cbl_refer_t& refer ) { return data_numeric_edited_e; case FldAlphaEdited: return data_alphanumeric_edited_e; - + case FldPointer: return data_data_pointer_e; - + case FldClass: case FldConditional: case FldForward: @@ -12159,7 +12159,7 @@ new_literal( const char initial[], enum radix_t radix ) { attr = bool_encoded_e; break; } - return new_literal(strlen(initial), initial, + return new_literal(strlen(initial), initial, cbl_field_attr_t(constant_e | attr)); } @@ -12276,7 +12276,7 @@ initialize_one( cbl_num_result_t target, bool with_filler, source.field = new_literal(ach); source.addr_of = true; } - + if( tgt.field->type == FldPointer ) { parser_set_pointers(1, &tgt, source); } else { @@ -12291,7 +12291,7 @@ initialize_one( cbl_num_result_t target, bool with_filler, /* * Either VALUE or REPLACING specified. */ - + if( value_category == data_category_all || value_category == data_category_of(tgt) ) { // apply any applicable VALUE @@ -12329,19 +12329,19 @@ initialize_one( cbl_num_result_t target, bool with_filler, } return true; - + } typedef std::pair<cbl_field_t*,cbl_field_t*> field_span_t; typedef std::pair<size_t, size_t> cbl_bytespan_t; static void -dump_spans( size_t isym, +dump_spans( size_t isym, const cbl_field_t *table, const std::list<field_span_t>& spans, size_t nrange, const cbl_bytespan_t ranges[], - size_t depth, + size_t depth, const std::list<cbl_subtable_t>& subtables ) { int i=0; @@ -12373,7 +12373,7 @@ dump_spans( size_t isym, dbgmsg("\t %02u %-20s to %02u %-20s: %3zu-%zu %s", span.first->level, span.first->name, last_level, last_name, - nrange? ranges[i].first : 1, + nrange? ranges[i].first : 1, nrange? ranges[i].second : 0, at_subtable); i++; @@ -12387,11 +12387,11 @@ dump_spans( size_t isym, } /* - * After the 1st record is initialized, copy it to the others. + * After the 1st record is initialized, copy it to the others. */ static bool initialize_table( cbl_num_result_t target, - size_t nspan, const cbl_bytespan_t spans[], + size_t nspan, const cbl_bytespan_t spans[], const std::list<cbl_subtable_t>& subtables ) { if( getenv("initialize_statement") ) { @@ -12414,7 +12414,7 @@ static cbl_refer_t synthesize_table_refer( cbl_refer_t tgt ) { // For a table, use supplied subscripts or start with 1. auto ndim( dimensions(tgt.field) ); - if( tgt.nsubscript < ndim ) { // it's an incomplete table + if( tgt.nsubscript < ndim ) { // it's an incomplete table cbl_refer_t subscripts[ndim]; for( size_t i=0; i < ndim; i++ ) { if( i < tgt.nsubscript ) { @@ -12466,7 +12466,7 @@ initialize_statement( const cbl_num_result_t& target, bool with_filler, bool fOK = true; std::list<cbl_field_t*> members; std::list<cbl_subtable_t> subtables; - + while( ++imember < eogroup ) { auto e = symbol_at(imember); if( e->type != SymField ) continue; @@ -12566,7 +12566,7 @@ initialize_statement( const cbl_num_result_t& target, bool with_filler, if( !with_filler && tgt.field->has_attr(filler_e) ) return true; cbl_num_result_t output = { target.rounded, synthesize_table_refer(tgt) }; - + bool fOK = initialize_one( output, with_filler, value_category, replacements, depth == 0 ); @@ -12597,7 +12597,7 @@ data_category_str( data_category_t category ) { case data_numeric_e: return "numeric"; case data_numeric_edited_e: return "numeric_edited"; case data_object_referenc_e: return "data_object_referenc"; - case data_program_pointer_e: return "data_program_pointer"; + case data_program_pointer_e: return "data_program_pointer"; } return "???"; } @@ -12729,7 +12729,7 @@ new_literal( const literal_t& lit, enum cbl_field_attr_t attr ) { bool zstring = lit.prefix[0] == 'Z'; if( !zstring && lit.data[lit.len] != '\0' ) { dbgmsg("%s:%d: line %d, no NUL terminator '%-*.*s'{%zu/%zu}", - __func__, __LINE__, yylineno, + __func__, __LINE__, yylineno, int(lit.len), int(lit.len), lit.data, strlen(lit.data), lit.len); } @@ -12926,7 +12926,7 @@ literal_refmod_valid( YYLTYPE loc, const cbl_refer_t& r ) { if( r.field->has_attr(any_length_e) ) return true; const cbl_span_t& refmod(r.refmod); - + if( ! is_literal(refmod.from->field) ) { if( ! refmod.len ) return true; if( ! is_literal(refmod.len->field) ) return true; @@ -12936,9 +12936,9 @@ literal_refmod_valid( YYLTYPE loc, const cbl_refer_t& r ) { } // len < 0 or not: 0 < from + len <= capacity error_msg(loc, "%s(%s:%zu) out of bounds, " - "size is %u", + "size is %u", r.field->name, - refmod.from->name(), + refmod.from->name(), size_t(refmod.len->field->data.value), static_cast<unsigned int>(r.field->data.capacity) ); return false; @@ -12952,11 +12952,11 @@ literal_refmod_valid( YYLTYPE loc, const cbl_refer_t& r ) { if( refmod.len->field->data.value > 0 ) { edge += refmod.len->field->data.value; if( --edge < r.field->data.capacity ) return true; - } + } // len < 0 or not: 0 < from + len <= capacity auto loc = symbol_field_location(field_index(r.field)); error_msg(loc, "%s(%zu:%zu) out of bounds, " - "size is %u", + "size is %u", r.field->name, size_t(refmod.from->field->data.value), size_t(refmod.len->field->data.value), @@ -12965,7 +12965,7 @@ literal_refmod_valid( YYLTYPE loc, const cbl_refer_t& r ) { } } // not: 0 < from <= capacity - error_msg(loc,"%s(%zu) out of bounds, size is %u", + error_msg(loc,"%s(%zu) out of bounds, size is %u", r.field->name, size_t(refmod.from->field->data.value), static_cast<unsigned int>(r.field->data.capacity) ); @@ -13038,7 +13038,7 @@ require_pointer( YYLTYPE loc, cbl_refer_t scalar ) { } static bool -require_numeric( YYLTYPE loc, cbl_refer_t scalar ) { +require_numeric( YYLTYPE loc, cbl_refer_t scalar ) { if( ! is_numeric(scalar.field) ) { error_msg(loc, "%s must have numeric USAGE", scalar.name()); return false; @@ -13086,7 +13086,7 @@ eval_subject_t::compatible( const cbl_field_t *object ) const { cbl_field_t * eval_subject_t::compare( int token ) { size_t tf( very_false_register() ); - + switch( token ) { case ANY: parser_logop(result, @@ -13129,7 +13129,7 @@ cbl_field_t * eval_subject_t::compare( const cbl_refer_t& object, const cbl_refer_t& object2 ) { auto subject(*pcol); - + if( ! compatible( object.field ) ) { if( yydebug ) { dbgmsg("%s:%d: failed for %s %s", @@ -13148,20 +13148,20 @@ eval_subject_t::compare( const cbl_refer_t& object, return nullptr; } } - + if( is_conditional(subject.field) ) { assert( object2.field == nullptr ); parser_logop(result, subject.field, xnor_op, object.field); return result; } - + if( object2.field ) { assert( ! is_conditional(object.field) ); assert( ! is_conditional(object2.field) ); cbl_field_t * gte = new_temporary(FldConditional); cbl_field_t * lte = new_temporary(FldConditional); - + parser_relop( gte, object, le_op, subject ); parser_relop( lte, subject, le_op, object2 ); @@ -13172,4 +13172,3 @@ eval_subject_t::compare( const cbl_refer_t& object, parser_relop(result, subject, eq_op, object); return result; } - diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index e3f125489847ea3108969cef8ec99616468b9b1f..c5099a48f3e2c7145749cc91e36c1a151f68d66c 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -78,25 +78,25 @@ static size_t nparse_error = 0; size_t parse_error_inc() { return ++nparse_error; } size_t parse_error_count() { return nparse_error; } void input_file_status_notify(); - -#define YYLLOC_DEFAULT(Current, Rhs, N) \ + +#define YYLLOC_DEFAULT(Current, Rhs, N) \ do { \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - location_dump("parse.c", N, \ - "rhs N ", YYRHSLOC (Rhs, N)); \ - } \ - else \ - { \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + location_dump("parse.c", N, \ + "rhs N ", YYRHSLOC (Rhs, N)); \ + } \ + else \ + { \ (Current).first_line = \ - (Current).last_line = YYRHSLOC (Rhs, 0).last_line; \ + (Current).last_line = YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = \ - (Current).last_column = YYRHSLOC (Rhs, 0).last_column; \ - } \ + (Current).last_column = YYRHSLOC (Rhs, 0).last_column; \ + } \ location_dump("parse.c", __LINE__, "current", (Current)); \ gcc_location_set( location_set(Current) ); \ input_file_status_notify(); \ @@ -110,7 +110,7 @@ extern int yydebug; const char * consistent_encoding_check( const YYLTYPE& loc, const char input[] ) { cbl_field_t faux = { - .type = FldAlphanumeric, + .type = FldAlphanumeric, .data = { .capacity = capacity_cast(strlen(input)), .initial = input } }; @@ -211,7 +211,7 @@ namcpy(const YYLTYPE& loc, cbl_name_t tgt, const char *src ) { auto len = snprintf(tgt, sizeof(cbl_name_t), "%s", src); if( ! (0 < len && len < int(sizeof(cbl_name_t))) ) { error_msg(loc, "name truncated to '%s' (max %zu characters)", - tgt, sizeof(cbl_name_t)-1); + tgt, sizeof(cbl_name_t)-1); return false; } return true; @@ -322,9 +322,9 @@ struct evaluate_elem_t { label = protolabel; label.line = yylineno; if( -1 == snprintf(label.name, sizeof(label.name), - "%.*s_%d", (int)sizeof(label.name)-6, skel, yylineno) ) { + "%.*s_%d", (int)sizeof(label.name)-6, skel, yylineno) ) { yyerror("could not create unique label '%s_%d' because it is too long", - skel, yylineno); + skel, yylineno); } } @@ -608,17 +608,17 @@ class eval_subject_t { } size_t subject_count() const { return columns.size(); } size_t object_count() { return std::distance(columns.begin(), pcol); } - + void object_relop( relop_t op ) { abbr_relop = op; } relop_t object_relop() const { return abbr_relop; } void rewind() { pcol = columns.begin(); } - + bool compatible( const cbl_field_t *object ) const; - // compare sets result - cbl_field_t * compare( int token ); - cbl_field_t * compare( relop_t op, + // compare sets result + cbl_field_t * compare( int token ); + cbl_field_t * compare( relop_t op, const cbl_refer_t& object, bool deciding = false); cbl_field_t * compare( const cbl_refer_t& object, const cbl_refer_t& object2 = nullptr); @@ -633,7 +633,7 @@ class eval_subject_t { } // decide() calls codegen with the result and increments the subject column. - // On FALSE, skip past <statements> and fall into next WHEN. + // On FALSE, skip past <statements> and fall into next WHEN. bool decided( cbl_field_t *result ) { this->result = result; parser_if( result ); @@ -683,7 +683,7 @@ class eval_subject_t { } pcol++; return true; - } + } bool decide( const cbl_refer_t& object, const cbl_refer_t& object2, bool invert ) { if( pcol == columns.end() ) return false; if( compare(object, object2) ) { @@ -738,9 +738,9 @@ struct perform_t { *fini, // Format 3, code that reverts handlers *top, // Format 3, above imperative-statement-1 *from, // Format 3, imperative-statement-1 - *finally, + *finally, *other, *common; - ec_labels_t() + ec_labels_t() : init(NULL), fini(NULL), top(NULL), from(NULL), finally(NULL), other(NULL), common(NULL) @@ -757,7 +757,7 @@ struct perform_t { static cbl_label_t * new_label( cbl_label_type_t type, const cbl_name_t role ); } ec_labels; - + struct { cbl_label_t *start, *end; cbl_field_t *unsatisfied, *size; @@ -828,7 +828,7 @@ perform_ec_cleanup() { /* ... empty init block ... */ parser_label_goto(perf->ec_labels.top); parser_label_label(perf->ec_labels.fini); -#endif +#endif } static list<cbl_label_t*> searches; @@ -882,13 +882,13 @@ typedef list<cbl_domain_t>::iterator domain_iter; * returned as a NAME or NAME88 token. NAME88 is returned only if a correctly, * uniquely specified Level 88 data item is found in the symbol table (because * else we can't know). - * + * * When the parser gets a NAME or NAME88 token, it retrieves the pending list * of qualifiers, if any, from the name queue. It adds the returned name to * the list and calls symbol_find() to search the name map. For correctly * specified names, the lexer has already done that work, which is now * unfortunately repeated. For incorrect names, the parser emits a most useful - * diagnostic. + * diagnostic. */ static name_queue_t name_queue; @@ -901,7 +901,7 @@ tee_up_name( const YYLTYPE& loc, const char name[] ) { name_queue.push(loc, name); } cbl_namelist_t -teed_up_names() { +teed_up_names() { return name_queue_t::namelist_of( name_queue.peek() ); } @@ -916,11 +916,11 @@ class tokenset_t { std::transform(name, name + strlen(name) + 1, lname, ftolower); return lname; } - + public: tokenset_t(); int find( const cbl_name_t name, bool include_intrinsics ); - + bool equate( const YYLTYPE& loc, int token, const cbl_name_t name ) { auto lname( lowercase(name) ); auto cw = cobol_words.insert(lname); @@ -988,7 +988,7 @@ class current_tokens_t { public: current_tokens_t() {} int find( const cbl_name_t name, bool include_intrinsics ) { - return tokens.find(name, include_intrinsics); + return tokens.find(name, include_intrinsics); } bool equate( const YYLTYPE& loc, cbl_name_t keyword, const cbl_name_t name ) { int token = keyword_tok(keyword); @@ -1304,9 +1304,9 @@ struct ffi_args_t { int i=0; for( const auto& arg : elems ) { dbgmsg( "%8d) %-10s %-16s %s", i++, - cbl_ffi_crv_str(arg.crv), - 3 + cbl_field_type_str(arg.refer.field->type), - arg.refer.field->pretty_name() ); + cbl_ffi_crv_str(arg.crv), + 3 + cbl_field_type_str(arg.refer.field->type), + arg.refer.field->pretty_name() ); } } @@ -1421,8 +1421,8 @@ class prog_descr_t { locale_t(const cbl_name_t name = NULL, const char *os_name = NULL) : name(""), os_name(os_name) { if( name ) { - bool ok = namcpy(YYLTYPE(), this->name, name); - gcc_assert(ok); + bool ok = namcpy(YYLTYPE(), this->name, name); + gcc_assert(ok); } } } locale; @@ -1481,7 +1481,7 @@ struct cbl_typedef_less { if( result > 0 ) return false; // Names that match are different if they're in different programs - // and neither is external. + // and neither is external. auto lhs = field_index(a); auto rhs = field_index(b); if( lhs != rhs ) { @@ -1540,7 +1540,7 @@ class program_stack_t : protected std::stack<prog_descr_t> { return pending.call_convention = convention; } bool pending_initial() { return pending.initial = true; } - + void push( prog_descr_t descr ) { cbl_call_convention_t current_call_convention = cbl_call_cobol_e; if( !empty() ) current_call_convention = top().call_convention; @@ -1570,8 +1570,8 @@ class program_stack_t : protected std::stack<prog_descr_t> { } void apply_pending() { - if( size() == 1 && 0 != pending.call_convention ) { - top().call_convention = pending.call_convention; + if( size() == 1 && 0 != pending.call_convention ) { + top().call_convention = pending.call_convention; } if( pending.initial ) { auto e = symbol_at(top().program_index); @@ -1613,7 +1613,7 @@ struct rel_part_t { return *this; } - bool is_value() const { return operand && is_elementary(operand->field->type); } + bool is_value() const { return operand && is_elementary(operand->field->type); } }; /* @@ -1641,13 +1641,13 @@ class log_expr_t { __func__, __LINE__, name_of(init)); } } - + cbl_field_t * and_term() { return andable; } log_expr_t * and_term( cbl_field_t *rhs ) { if( ! is_conditional(rhs) ) { - dbgmsg("%s:%d: logic error: %s is not a truth value", + dbgmsg("%s:%d: logic error: %s is not a truth value", __func__, __LINE__, name_of(rhs)); } else { parser_logop( andable, andable, and_op, rhs ); @@ -1656,10 +1656,10 @@ class log_expr_t { } log_expr_t * or_term( cbl_field_t *rhs ) { if( ! is_conditional(rhs) ) { - dbgmsg("%s:%d: logic error: %s is not a truth value", + dbgmsg("%s:%d: logic error: %s is not a truth value", __func__, __LINE__, name_of(rhs)); return this; - } + } if( ! orable ) { orable = andable; } else { @@ -1714,7 +1714,7 @@ static class current_t { parser_entry_activate( iprog, eval ); auto name = cbl_label_of(symbol_at(iprog))->name; cbl_unimplemented("Global declarative %s for %s", - eval->name, name); + eval->name, name); parser_call( new_literal(strlen(name), name, quoted_e), cbl_refer_t(), 0, NULL, NULL, NULL, false ); } @@ -2001,7 +2001,7 @@ static class current_t { options_paragraph = cbl_options_t(); first_statement = 0; - + return fOK; } @@ -2029,18 +2029,18 @@ static class current_t { bool is_first_statement( const YYLTYPE& loc ) { if( ! in_declaratives && first_statement == 0 ) { if( ! symbol_label_section_exists(program_index()) ) { - if( ! dialect_ibm() ) { - error_msg(loc, - "Per ISO a program with DECLARATIVES must begin with a SECTION, " - "requires -dialect ibm"); - } + if( ! dialect_ibm() ) { + error_msg(loc, + "Per ISO a program with DECLARATIVES must begin with a SECTION, " + "requires -dialect ibm"); + } } first_statement = loc.first_line; return true; } return false; } - + /* * At the end of each program, ensure there are no uses of an ambiguous * procedure (SECTION or PARAGRAPH) name. At the end of a top-level program, @@ -2143,8 +2143,8 @@ static class current_t { return lave_label; } - cbl_label_t * new_section( cbl_label_t * section ) { - std::swap( programs.top().section, section ); + cbl_label_t * new_section( cbl_label_t * section ) { + std::swap( programs.top().section, section ); return section; } @@ -2215,7 +2215,7 @@ static class current_t { */ void declaratives_evaluate( ec_type_t handled = ec_none_e ) { - // The exception file number is assumed to be zero unless it has been + // The exception file number is assumed to be zero unless it has been // changed to a non-zero value. The program picking it up and referencing // it is charged with setting it back to zero. // parser_set_file_number(0); @@ -2234,7 +2234,7 @@ static class current_t { } void antecedent_dump() const { - if( ! yydebug ) return; + if( ! yydebug ) return; if( ! antecedent_cache.operand ) { yywarn( "Antecedent: none" ); } else { @@ -2254,7 +2254,7 @@ static class current_t { return antecedent_cache; } rel_part_t& antecedent_invert( bool invert=true ) { - antecedent_cache.invert = invert; + antecedent_cache.invert = invert; antecedent_dump(); return antecedent_cache; } @@ -2462,7 +2462,7 @@ is_callable( const cbl_field_t *field ) { struct cbl_fieldloc_t { YYLTYPE loc; cbl_field_t *field; - + cbl_fieldloc_t() : loc{ 1,1, 1,1 }, field(NULL) {} cbl_fieldloc_t( const YYLTYPE& loc, cbl_field_t *field ) : loc(loc), field(field) @@ -2485,7 +2485,7 @@ intrinsic_call_0( cbl_field_t *output, int token ) { static bool intrinsic_call_1( cbl_field_t *output, int token, - cbl_refer_t *r1, const YYLTYPE& loc ) { + cbl_refer_t *r1, const YYLTYPE& loc ) { std::vector<cbl_refer_t> args { *r1 }; if( 0 == intrinsic_invalid_parameter(token, args) ) { error_msg(loc, "invalid parameter '%s'", r1->field->name); @@ -2629,7 +2629,7 @@ symbol_find( const YYLTYPE& loc, const char *name ) { auto names = name_queue.pop_as_names(); } names.push_front(name); - auto found = symbol_find( PROGRAM, names ); + auto found = symbol_find( PROGRAM, names ); if( found.first && !found.second ) { auto field = cbl_field_of(found.first); error_msg(loc, "'%s' is not unique, first defined on line %d", @@ -2646,13 +2646,13 @@ register_find( const char *name ) { static bool valid_redefine( const YYLTYPE& loc, - const cbl_field_t *field, const cbl_field_t *orig ) { + const cbl_field_t *field, const cbl_field_t *orig ) { // Must have same level. if( field->level != orig->level ) { error_msg(loc, "cannot redefine %s %s as %s %s " - "because they have different levels", - orig->level_str(), orig->name, - field->level_str(), field->name); + "because they have different levels", + orig->level_str(), orig->name, + field->level_str(), field->name); return false; } @@ -2675,34 +2675,34 @@ valid_redefine( const YYLTYPE& loc, if( e != sym.field ) { auto wrong = cbl_field_of(e); error_msg(loc, "%s %s on line %d lies between %s and %s", - wrong->level_str(), wrong->name, wrong->line, - orig->name, field->name); + wrong->level_str(), wrong->name, wrong->line, + orig->name, field->name); return false; } // cannot redefine a table if( orig->occurs.ntimes() ) { error_msg(loc, "cannot redefine table %s %s", - orig->level_str(), orig->name); + orig->level_str(), orig->name); return false; } // redefined field cannot be ODO if( orig->occurs.depending_on ) { error_msg(loc, "redefined data item %s %s has OCCURS DEPENDING ON", - orig->level_str(), orig->name); + orig->level_str(), orig->name); return false; } // redefiner cannot have ODO if( field->occurs.depending_on ) { error_msg(loc, "data item %s %s cannot use REDEFINES and OCCURS DEPENDING ON", - field->level_str(), field->name); + field->level_str(), field->name); return false; } if( is_variable_length(orig) ) { error_msg(loc, "redefined data item %s %s has OCCURS DEPENDING ON", - orig->level_str(), orig->name); + orig->level_str(), orig->name); return false; } // We don't know about the redefining group until it's completely defined. @@ -2717,8 +2717,8 @@ valid_redefine( const YYLTYPE& loc, if( field->type != FldGroup && orig->type != FldGroup ) { if( orig->size() < field->size() ) { if( orig->level > 1 || orig->has_attr(external_e) ) { - dbgmsg( "size error orig: %s", field_str(orig) ); - dbgmsg( "size error redef: %s", field_str(field) ); + dbgmsg( "size error orig: %s", field_str(orig) ); + dbgmsg( "size error redef: %s", field_str(field) ); error_msg(loc, "%s (%s size %u) larger than REDEFINES %s (%s size %u)", field->name, 3 + cbl_field_type_str(field->type), field->size(), @@ -2745,8 +2745,8 @@ valid_redefine( const YYLTYPE& loc, if( ! same_group ) { error_msg(loc, "cannot redefine %s %s as %s %s " "because they belong to different groups", - orig->level_str(), orig->name, - field->level_str(), field->name); + orig->level_str(), orig->name, + field->level_str(), field->name); return false; } @@ -2816,7 +2816,7 @@ field_add( const YYLTYPE& loc, cbl_field_t *field ) { break; } - // Use isym 0 to indicate the location of the field under construction. + // Use isym 0 to indicate the location of the field under construction. symbol_field_location(0, loc); struct symbol_elem_t *e = symbol_field_add(PROGRAM, field); @@ -2831,7 +2831,7 @@ field_add( const YYLTYPE& loc, cbl_field_t *field ) { break; default: error_msg(loc, "%s %s is not part of an 01 record", - field->level_str(), field->name ); + field->level_str(), field->name ); return NULL; break; } @@ -2862,8 +2862,8 @@ uniform_picture( const char *picture, char model ) { [model]( char ch ) { return model == TOLOWER(ch); } ); -} - +} + static enum cbl_field_attr_t uniform_picture( const char *picture ) { static char ch[] = { 'A', 'X' }; @@ -2876,11 +2876,11 @@ uniform_picture( const char *picture ) { } } return none_e; -} +} static bool field_type_update( cbl_field_t *field, cbl_field_type_t type, - YYLTYPE loc, + YYLTYPE loc, bool is_usage = false) { // preserve NumericEdited if already established @@ -2912,7 +2912,7 @@ field_type_update( cbl_field_t *field, cbl_field_type_t type, } dbgmsg( "%s:%d: %s became %s based on %s", __func__, __LINE__, field->name, - cbl_field_type_str(field->type), cbl_field_type_str(type) ); + cbl_field_type_str(field->type), cbl_field_type_str(type) ); return true; } @@ -2937,7 +2937,7 @@ field_capacity_error( const YYLTYPE& loc, const cbl_field_t *field ) { } return false; } -#define ERROR_IF_CAPACITY(L, F) \ +#define ERROR_IF_CAPACITY(L, F) \ do { if( field_capacity_error(L, F) ) YYERROR; } while(0) static const char * @@ -2959,7 +2959,7 @@ static bool value_encoding_check( const YYLTYPE& loc, cbl_field_t *field ) { if( ! field->internalize() ) { error_msg(loc, "inconsistent string literal encoding for '%s'", - field->data.initial); + field->data.initial); return false; } return true; @@ -3029,7 +3029,7 @@ alphabet_add( const YYLTYPE& loc, cbl_encoding_t encoding ) { return cbl_alphabet_of(e); } -// The current field always exists in the symbol table, even if it's incomplete. +// The current field always exists in the symbol table, even if it's incomplete. static cbl_field_t * current_field(cbl_field_t * field = NULL) { static cbl_field_t *local; @@ -3075,8 +3075,8 @@ parser_move_carefully( const char */*F*/, int /*L*/, if( is_index ) { if( tgt.field->type != FldIndex && src.field->type != FldIndex) { error_msg(src.loc, "invalid SET %s (%s) TO %s (%s): not a field index", - tgt.field->name, cbl_field_type_str(tgt.field->type), - src.field->name, cbl_field_type_str(src.field->type)); + tgt.field->name, cbl_field_type_str(tgt.field->type), + src.field->name, cbl_field_type_str(src.field->type)); delete tgt_list; return false; } @@ -3479,7 +3479,7 @@ file_section_parent_set( cbl_field_t *field ) { } void ast_call(const YYLTYPE& loc, cbl_refer_t name, - cbl_refer_t returning, + cbl_refer_t returning, size_t narg, cbl_ffi_arg_t args[], cbl_label_t *except, cbl_label_t *not_except, @@ -3499,13 +3499,13 @@ ast_end_program(const char name[] ) { auto& L( *cbl_label_of(&elem) ); if( L.used ) { if( ! L.lain ) { - YYLTYPE loc { L.line, 1, L.line, 1 }; + YYLTYPE loc { L.line, 1, L.line, 1 }; error_msg(loc, "line %d: %s " "is used on line %d and never defined", L.line, L.name, L.used ); } - dbgmsg("label: %.20s: %d/%d/%d", - L.name, L.line, L.lain, L.used); + dbgmsg("label: %.20s: %d/%d/%d", + L.name, L.line, L.lain, L.used); } } } ); @@ -3524,7 +3524,7 @@ goodnight_gracie() { assert(prog); std::set<std::string> externals = current.end_program(); - + if( !externals.empty() ) { for( const auto& name : externals ) { yywarn("%s calls external symbol '%s'", @@ -3558,5 +3558,3 @@ static void ast_first_statement( const YYLTYPE& loc ) { parser_first_statement(loc.first_line); } } - - diff --git a/gcc/cobol/posix/udf/Makefile b/gcc/cobol/posix/udf/Makefile index a6990fbdc3274aebfd800d4ff421b03c1268c4e7..8321f2dde90f8cd9865b021e2cdc9fe31bedd22f 100644 --- a/gcc/cobol/posix/udf/Makefile +++ b/gcc/cobol/posix/udf/Makefile @@ -9,7 +9,7 @@ t/errno: t/errno.cbl posix-mkdir.cbl | libposix-errno.so ../../built-gcobol $(FLAGS) -o $@ -I$$(pwd) \ $(firstword $^) $(LDFLAGS) -lposix-errno -libposix-errno.so: ../c/posix_errno.c posix-errno.o +libposix-errno.so: ../c/posix_errno.c posix-errno.o gcc $(CFLAGS) -shared -o $@ $^ posix-errno.o: posix-errno.cbl diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l index 2c997faa31af77d356ba87119a16adfb4a334abf..7711be7cafb5c5cb6c5c9ddf235c57b91183e143 100644 --- a/gcc/cobol/scan.l +++ b/gcc/cobol/scan.l @@ -78,14 +78,14 @@ OSPC [[:space:]]* EOL \r?\n BLANK_EOL [[:blank:]]*{EOL} BLANK_OEOL [[:blank:]]*{EOL}? - + DOTSEP [.][[:space:]] DOTEOL [[:blank:]]*[.]{BLANK_EOL} SKIP [[:blank:]]*SKIP[123][[:blank:]]*[.]?{BLANK_EOL} TITLE [[:blank:]]*TITLE($|[.]|[^\n]*) - + COUNT [(][[:digit:]]+[)] N9 9+|(9{COUNT}) NP P+|(P{COUNT}) @@ -173,7 +173,7 @@ PUSH_FILE \f?[#]FILE{SPC}PUSH{SPC}[^\f]+\f POP_FILE \f?[#]FILE{SPC}POP\f LINE_DIRECTIVE [#]line{SPC}[[:alnum:]]+{SPC}[""''].+\n -%x procedure_div ident_state addr_of function classify +%x procedure_div ident_state addr_of function classify %x program_id_state comment_entries %x author_state date_state field_level field_state dot_state %x numeric_state name_state @@ -214,7 +214,7 @@ LINE_DIRECTIVE [#]line{SPC}[[:alnum:]]+{SPC}[""''].+\n } if( 0 == yyleng % 2 ) { yylval.literal.set_data( yyleng/2, hex_decode(yytext) ); - update_location_col(yytext, -3); + update_location_col(yytext, -3); return LITERAL; } dbgmsg( "hex literal '%s' " @@ -273,7 +273,7 @@ PROCEDURE{SPC}DIVISION { yy_push_state(procedure_div); [[:blank:]]*(ENVIRONMENT|DATA|PROCEDURE)[[:blank:]]+DIVISION/.+\n { yy_pop_state(); myless(0); } [[:blank:]]*AUTHOR[[:blank:].]+{EOL}? { - // Might not have an EOL, but stop on one. + // Might not have an EOL, but stop on one. yy_push_state(author_state); } {DOTEOL} @@ -869,7 +869,7 @@ ACCESS { return ACCESS; } ACCEPT { return ACCEPT; } DELETE { return DELETE; } -EJECT{DOTEOL}? { +EJECT{DOTEOL}? { if( ! dialect_ibm() ) { dialect_error(yylloc, "EJECT is not ISO syntax,", "ibm"); } @@ -960,7 +960,7 @@ USE({SPC}FOR)? { return USE; } USAGE { return USAGE; } UNBOUNDED { return UNBOUNDED; } /* use coded capacity 255 to indicate comp-x */ - COMP(UTATIONAL)?-X { return ucomputable(FldNumericBin5, 0xFF); } + COMP(UTATIONAL)?-X { return ucomputable(FldNumericBin5, 0xFF); } COMP(UTATIONAL)?-6 { return ucomputable(FldPacked, 0); } COMP(UTATIONAL)?-5 { return ucomputable(FldNumericBin5, 0); } COMP(UTATIONAL)?-4 { return scomputable(FldNumericBinary, 0); } @@ -1012,7 +1012,7 @@ USE({SPC}FOR)? { return USE; } PROCEDURE-POINTER { if( dialect_gcc() ) { error_msg(yylloc, "%s requires -dialect ibm or mf", yytext); } - yylval.field_attr = prog_ptr_e; + yylval.field_attr = prog_ptr_e; return POINTER; // return it anyway } @@ -1051,7 +1051,7 @@ USE({SPC}FOR)? { return USE; } DEPENDING { return DEPENDING; } DESCENDING { return DESCENDING; } DISPLAY { return DISPLAY; } - EJECT{DOTEOL}? { + EJECT{DOTEOL}? { if( ! dialect_ibm() ) { dialect_error(yylloc, "EJECT is not ISO syntax,", "ibm"); } @@ -1136,7 +1136,7 @@ USE({SPC}FOR)? { return USE; } PROCEDURE{SPC}DIVISION { BEGIN(procedure_div); return PROCEDURE_DIV; } - [*]>.*$ // ignore inline comment + [*]>.*$ // ignore inline comment } <numstr_state>{ @@ -1174,8 +1174,8 @@ USE({SPC}FOR)? { return USE; } * * On entry, we might have found a newline. If so, we accept any leading * blanks, and ignore blank lines. This sets up recognizing SKIP2 etc. - * - * Any blank or separator period ends terminates the picture. + * + * Any blank or separator period ends terminates the picture. */ <picture>{ ^[[:blank:]]+ @@ -1198,7 +1198,7 @@ USE({SPC}FOR)? { return USE; } {N9}/{N9}*[,.]? { yylval.number = ndigit(yyleng); return picset(NINES); } P+/[,.]?\r?\n { yylval.number = yyleng; return picset(PIC_P); } - {ALNUM}/{COUNT}({ALNUM}{COUNT}?)+ { + {ALNUM}/{COUNT}({ALNUM}{COUNT}?)+ { yy_push_state(picture_count); yylval.string = xstrdup(yytext); return picset(ALNUM); } {ALNUM}/{COUNT} { yy_push_state(picture_count); @@ -1263,10 +1263,10 @@ USE({SPC}FOR)? { return USE; } Z?['']{STRING1}[''] { auto *s = xstrdup(yytext); std::replace(s, s + strlen(s), '\'', '"'); ydflval.string = s; - update_location_col(s); + update_location_col(s); return LITERAL; } Z?[""]{STRING}[""] { ydflval.string = xstrdup(yytext); - update_location_col(yytext); + update_location_col(yytext); return LITERAL; } [=]{4} { static char nullstring[] = ""; ydflval.string = nullstring; return PSEUDOTEXT; } @@ -1277,7 +1277,7 @@ USE({SPC}FOR)? { return USE; } [^=]+[=]/[^=] { tmpstring_append(yyleng); } [^=]+/[=]{2} { yylval.string = xstrdup(tmpstring_append(yyleng)); ydflval.string = yylval.string; - update_location_col(yylval.string); + update_location_col(yylval.string); return PSEUDOTEXT; } [=]{2} { tmpstring = NULL; yy_pop_state(); } } @@ -1295,7 +1295,7 @@ USE({SPC}FOR)? { return USE; } char *s = xstrdup(tmpstring? tmpstring : "\0"); yylval.literal.set_data(strlen(s), s); ydflval.string = yylval.literal.data; - update_location_col(yylval.literal.data, -2); + update_location_col(yylval.literal.data, -2); tmpstring = NULL; pop_return LITERAL; } } @@ -1312,7 +1312,7 @@ USE({SPC}FOR)? { return USE; } char *s = xstrdup(tmpstring? tmpstring : "\0"); yylval.literal.set_data(strlen(s), s); ydflval.string = yylval.literal.data; - update_location_col(yylval.literal.data, -2); + update_location_col(yylval.literal.data, -2); tmpstring = NULL; pop_return LITERAL; } } @@ -1646,7 +1646,7 @@ USE({SPC}FOR)? { return USE; } std::transform( p, p + sizeof(name2), name2, []( char ch ) { switch(ch) { - case '-': + case '-': case '_': return ch; default: if( ISALNUM(ch) ) return ch; @@ -1654,9 +1654,9 @@ USE({SPC}FOR)? { return USE; } return '\0'; } ); symbol_elem_t *e = symbol_file(PROGRAM, name2); - /* - * For NAME IN FILENAME, we want the parser to handle it. - * For NAME IN NAME (of filename), the scanner handles it. + /* + * For NAME IN FILENAME, we want the parser to handle it. + * For NAME IN NAME (of filename), the scanner handles it. */ if( e ) { // e is an FD, but name2 could be its 01 cbl_namelist_t names = {name2, yytext}; @@ -1693,9 +1693,9 @@ USE({SPC}FOR)? { return USE; } } return NAME; } - {NAME}{OSPC}/[(] { BEGIN(subscripts); + {NAME}{OSPC}/[(] { BEGIN(subscripts); auto name = xstrdup(yytext); - char *eoname = name + strlen(name); + char *eoname = name + strlen(name); auto p = std::find_if(name, eoname, fisspace); // stop at blank, if any if( p < eoname ) *p = '\0'; @@ -1766,7 +1766,7 @@ USE({SPC}FOR)? { return USE; } case 'd': token = DATE_FMT; break; case 't': token = TIME_FMT; break; default: - dbgmsg("format must be literal"); + dbgmsg("format must be literal"); pop_return token; break; } @@ -1963,7 +1963,7 @@ BASIS { yy_push_state(basis); return BASIS; } int token = keyword_tok(null_trim(yylval.string), true); - if( token && ! symbol_field(PROGRAM, 0, yylval.string) ) { + if( token && ! symbol_field(PROGRAM, 0, yylval.string) ) { // If token is an intrinsic, and not in Repository, pretend // it's a name and let the parser sort it out. auto name = intrinsic_function_name(token); @@ -1972,7 +1972,7 @@ BASIS { yy_push_state(basis); return BASIS; } return token; // intrinsic and in repository } error_msg(yylloc, "'FUNCTION %s' required because %s " - "is not mentioned in REPOSITORY paragraph", + "is not mentioned in REPOSITORY paragraph", name, name); } @@ -2084,7 +2084,7 @@ BASIS { yy_push_state(basis); return BASIS; } RESERVE { return RESERVE; } {NAME} { ydflval.string = yylval.string = xstrdup(yytext); - pop_return NAME; + pop_return NAME; } } @@ -2417,7 +2417,7 @@ BASIS { yy_push_state(basis); return BASIS; } WITH { return WITH; } WORKING-STORAGE { return WORKING_STORAGE; } WRITE { return WRITE; } - + ZERO | ZEROES | ZEROS { return ZERO; } diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc index 557b7c3fb7d9679d9f905be6c03b117e801dda29..1a5405259afbaa6491d9000e3d2e2f742490a588 100644 --- a/gcc/cobol/symbols.cc +++ b/gcc/cobol/symbols.cc @@ -84,7 +84,7 @@ static struct symbol_table_t { size_t capacity, nelem; size_t first_program, procedures; struct { - size_t file_status, linage_counter, return_code, + size_t file_status, linage_counter, return_code, exception_condition, very_true, very_false; } registers; @@ -136,7 +136,7 @@ symbol_table_extend() { } else { if( 0 != msync(symbols.elems, symbols.size(), MS_SYNC | MS_INVALIDATE) ) { cbl_err( "%s:%d: could not synchronize symbol table with mapped file", - __func__, __LINE__ ); + __func__, __LINE__ ); } } @@ -261,8 +261,8 @@ symbol_valid_udf_args( size_t function, std::list<cbl_refer_t> args ) { e++; // skip over linkage_sect_e, which appears after the function if( e->type != SymField ) { ERROR_FIELD(arg.field, - "FUNCTION %s has no defined parameter matching arg %zu, '%s'", - L->name, iarg, arg.field->name ); + "FUNCTION %s has no defined parameter matching arg %zu, '%s'", + L->name, iarg, arg.field->name ); return NULL; } @@ -284,7 +284,7 @@ static const struct cbl_field_t empty_float = { 0, FldFloat, FldInvalid, intermediate_e, 0, 0, 0, nonarray, 0, "", - 0, cbl_field_t::linkage_t(), + 0, cbl_field_t::linkage_t(), {16, 16, 32, 0, NULL, NULL, {NULL}, {NULL}}, NULL }; static const struct cbl_field_t empty_comp5 = { @@ -299,7 +299,7 @@ static const struct cbl_field_t empty_comp5 = { #else # define CONSTANT_E intermediate_e #endif - + static struct cbl_field_t empty_literal = { 0, FldInvalid, FldInvalid, CONSTANT_E, 0, 0, 0, nonarray, 0, "", @@ -489,7 +489,7 @@ static bool label_cmp( const cbl_label_t& key, if( ! names_matched ) { if( 0 != strcasecmp(key.name, elem.name) ) return false; } - + switch( key.type ) { case LblNone: @@ -868,49 +868,49 @@ field_size( const struct cbl_field_t *field ) { const char * cbl_field_attr_str( cbl_field_attr_t attr ) { switch(attr) { - case none_e: return "none"; - case figconst_1_e: return "figconst_1"; - case figconst_2_e: return "figconst_2"; - case figconst_4_e: return "figconst_4"; - case rjust_e: return "rjust"; - case ljust_e: return "ljust"; - case zeros_e: return "zeros"; - case signable_e: return "signable"; - case constant_e: return "constant"; - case function_e: return "function"; - case quoted_e: return "quoted"; - case filler_e: return "filler"; - case _spare_e: return "temporary"; - case intermediate_e: return "intermediate"; - case embiggened_e: return "embiggened"; - case all_alpha_e: return "all_alpha"; - case all_x_e: return "all_x"; - case all_ax_e: return "all_ax"; - case prog_ptr_e: return "prog_ptr"; - case scaled_e: return "scaled"; - case refmod_e: return "refmod"; - case based_e: return "based"; - case any_length_e: return "any_length"; - case global_e: return "global"; - case external_e: return "external"; - case blank_zero_e: return "blank_zero"; - case linkage_e: return "linkage"; - case local_e: return "local"; - case leading_e: return "leading"; - case separate_e: return "separate"; - case envar_e: return "envar"; - case dnu_1_e: return "dnu_1"; - case bool_encoded_e: return "bool"; - case hex_encoded_e: return "hex"; - case depends_on_e: return "depends_on"; - case initialized_e: return "initialized"; - case has_value_e: return "has_value"; - case ieeedec_e: return "ieeedec"; - case big_endian_e: return "big"; - case same_as_e: return "same_as"; - case record_key_e: return "record_key"; - case typedef_e: return "typedef"; - case strongdef_e: return "strongdef"; + case none_e: return "none"; + case figconst_1_e: return "figconst_1"; + case figconst_2_e: return "figconst_2"; + case figconst_4_e: return "figconst_4"; + case rjust_e: return "rjust"; + case ljust_e: return "ljust"; + case zeros_e: return "zeros"; + case signable_e: return "signable"; + case constant_e: return "constant"; + case function_e: return "function"; + case quoted_e: return "quoted"; + case filler_e: return "filler"; + case _spare_e: return "temporary"; + case intermediate_e: return "intermediate"; + case embiggened_e: return "embiggened"; + case all_alpha_e: return "all_alpha"; + case all_x_e: return "all_x"; + case all_ax_e: return "all_ax"; + case prog_ptr_e: return "prog_ptr"; + case scaled_e: return "scaled"; + case refmod_e: return "refmod"; + case based_e: return "based"; + case any_length_e: return "any_length"; + case global_e: return "global"; + case external_e: return "external"; + case blank_zero_e: return "blank_zero"; + case linkage_e: return "linkage"; + case local_e: return "local"; + case leading_e: return "leading"; + case separate_e: return "separate"; + case envar_e: return "envar"; + case dnu_1_e: return "dnu_1"; + case bool_encoded_e: return "bool"; + case hex_encoded_e: return "hex"; + case depends_on_e: return "depends_on"; + case initialized_e: return "initialized"; + case has_value_e: return "has_value"; + case ieeedec_e: return "ieeedec"; + case big_endian_e: return "big"; + case same_as_e: return "same_as"; + case record_key_e: return "record_key"; + case typedef_e: return "typedef"; + case strongdef_e: return "strongdef"; } return "???"; } @@ -1197,7 +1197,7 @@ symbols_dump( size_t first, bool header ) { asprintf(&s, "%4zu %-18s %s (%s)", e->program, cbl_field_type_str(cbl_field_of(e)->type) + 3, field_str(cbl_field_of(e)), - odo_str? odo_str : + odo_str? odo_str : cbl_field_type_str(cbl_field_of(e)->usage) + 3); } break; @@ -1416,7 +1416,7 @@ static struct symbol_elem_t * group->data.capacity += field_size(field); group->data.memsize += field_memsize(field); - // If group has a parent that is a record area, expand it, too. + // If group has a parent that is a record area, expand it, too. if( 0 < group->parent ) { auto redefined = symbol_redefines(group); if( redefined && is_record_area(redefined) ) { @@ -1602,12 +1602,12 @@ value_or_figconst_name( const char *value ) { return normal_value_e == fig? value : cbl_figconst_str(fig); } -const char * -cbl_field_t::attr_str( const std::vector<cbl_field_attr_t>& attrs ) const +const char * +cbl_field_t::attr_str( const std::vector<cbl_field_attr_t>& attrs ) const { const char *sep = ""; char *out = NULL; - + for( auto attr : attrs ) { char *part = out; if( has_attr(attr) ) { @@ -1838,7 +1838,7 @@ size_t parse_error_count(); /* * This function produces a zero-filled level number, so 1 becomes "01". It's * needed because the diagnostic format string doesn't support zero-filled - * integer conversion or width. + * integer conversion or width. */ const char * cbl_field_t::level_str( uint32_t level ) { @@ -1918,7 +1918,7 @@ symbols_update( size_t first, bool parsed_ok ) { } } } - + bool size_invalid = field->data.memsize > 0 && symbol_redefines(field); if( size_invalid ) { // redefine of record area is ok auto redefined = symbol_redefines(field); @@ -1945,7 +1945,7 @@ symbols_update( size_t first, bool parsed_ok ) { // no field redefines the file's default record auto file = cbl_file_of(symbol_at(field->parent)); ERROR_FIELD(field, "line %d: %s lacks a file description", - file->line, file->name); + file->line, file->name); return 0; } } @@ -1953,7 +1953,7 @@ symbols_update( size_t first, bool parsed_ok ) { if( yydebug || parse_error_count() == 0 ) { if( field->type == FldInvalid ) { ERROR_FIELD(field, "line %d: %s %s requires PICTURE", - field->line, field->level_str(), field->name); + field->line, field->level_str(), field->name); } else { dbgmsg("%s: error: data item %s #%zu '%s' capacity %u rejected", @@ -1997,7 +1997,7 @@ symbols_update( size_t first, bool parsed_ok ) { p = symbol_at(--isym); continue; } - + // Verify REDEFINing field has no ODO components auto parent = symbol_redefines(field); if( parent && !is_record_area(parent) && is_variable_length(field) ) { @@ -2009,18 +2009,18 @@ symbols_update( size_t first, bool parsed_ok ) { if( field->type == FldInvalid ) { dbgmsg("%s:%d: %s", __func__, __LINE__, field_str(field)); ERROR_FIELD(field, "line %d: %s %s requires PICTURE", - field->line, field->level_str(), field->name); + field->line, field->level_str(), field->name); continue; } assert( ! field->is_typedef() ); - + if( parsed_ok ) parser_symbol_add(field); } finalize_symbol_map2(); if( yydebug ) dump_symbol_map2(); - + build_symbol_map(); int ninvalid = 0; @@ -2130,7 +2130,7 @@ symbol_find_forward_field( size_t program, const char name[] ) { &nelem, sizeof(key), symbol_elem_cmp ) ); if( !e ) dbgmsg("%s:%d: no forward reference for program %zu '%s'", - __func__, __LINE__, program, name); + __func__, __LINE__, program, name); return e; @@ -2159,7 +2159,7 @@ had_picture( const cbl_field_t *field ) { if( is_elementary(field->type) ) { switch(field->type) { case FldAlphanumeric: - // VALUE string for alphanumeric might mean no PICTURE. + // VALUE string for alphanumeric might mean no PICTURE. return field->data.initial == NULL; case FldNumericDisplay: case FldNumericEdited: @@ -2208,7 +2208,7 @@ symbol_in_file( symbol_elem_t *e ) { auto end = std::reverse_iterator<symbol_elem_t *>(symbols_begin()); auto p = std::find_if( beg, end, []( const symbol_elem_t& elem ) { - return elem.type == SymFilename; + return elem.type == SymFilename; } ); return p != end? &*p : NULL; @@ -2240,14 +2240,14 @@ symbol_field_parent_set( struct cbl_field_t *field ) return NULL; // 77/78 cannot be a parent } } - + if( prior->level == field->level ) { auto redefined = symbol_redefines(prior); if( redefined ) prior = redefined; field->parent = prior->parent; return cbl_field_of(symbol_at(field->parent)); } - + if( prior->level < field->level ) { if( prior->has_attr(same_as_e) ) { ERROR_FIELD(prior, "%s created with SAME AS or TYPE TO, cannot have new member %s", @@ -2285,9 +2285,9 @@ symbol_field_parent_set( struct cbl_field_t *field ) return false; } ); if( ! all_numeric ) { - auto loc = symbol_field_location(0); + auto loc = symbol_field_location(0); error_msg(loc, "%s %s invalid VALUE for numeric type %s", - field->level_str(), field->name, prior->name); + field->level_str(), field->name, prior->name); } } return prior; @@ -2360,7 +2360,7 @@ symbol_table_init(void) { // 01 ARGI is the current index into the argv array { 0, FldNumericBin5, FldInvalid, signable_e, 0, 0, 0, nonarray, 0, "_ARGI", 0, {}, {16, 16, MAX_FIXED_POINT_DIGITS, 0, NULL, NULL, {NULL}, {NULL}}, NULL }, - + // These last two don't require actual storage; they get BOOL var_decl_node // in parser_symbol_add() { 0, FldConditional, FldInvalid, constant_e , 0, 0, 0, nonarray, 0, @@ -2511,7 +2511,7 @@ symbol_append( const symbol_elem_t& elem ) { return e; } -cbl_label_t * +cbl_label_t * cbl_perform_tgt_t::finally( size_t program ) { assert(0 < ito); static const char fini[] = "_fini"; @@ -2521,7 +2521,7 @@ cbl_perform_tgt_t::finally( size_t program ) { assert(n < int(sizeof(fini))); symbol_elem_t elem = { .type = SymLabel, - .program = program, + .program = program, .elem = { .label = proto } }, *e; e = symbol_add(&elem); ifrom = symbol_index(e); @@ -2590,10 +2590,10 @@ struct symbol_elem_t * symbol_typedef_add( size_t program, struct cbl_field_t *field ) { assert(field); assert(field->is_typedef()); - + if( field->is_strongdef() && field->level != 1 ) { ERROR_FIELD(field, "%s %s STRONG TYPEDEF must be level 01", - field->level_str(), field->name); + field->level_str(), field->name); return NULL; } @@ -2734,14 +2734,14 @@ symbol_field_add( size_t program, struct cbl_field_t *field ) } /* - * TYPEDEF is relevant only in Data Division. + * TYPEDEF is relevant only in Data Division. */ struct symbol_elem_t * symbol_typedef( size_t program, const char name[] ) { auto beg = std::reverse_iterator<symbol_elem_t *>(symbols_end()); auto end = std::reverse_iterator<symbol_elem_t *>(symbols_begin(program)); - + auto p = std::find_if( beg, end, [name]( const symbol_elem_t& sym ) { if( sym.type == SymField ) { @@ -2794,7 +2794,7 @@ symbol_field( size_t program, size_t parent, const char name[] ) symbol_elem_t * symbol_register( const char name[] ) { - auto p = std::find_if(symbols_begin(), symbol_at(symbols.first_program), + auto p = std::find_if(symbols_begin(), symbol_at(symbols.first_program), [len = strlen(name), name]( auto e ) { if( e.type == SymField ) { if( strlen(cbl_field_of(&e)->name) == len ) { @@ -2803,7 +2803,7 @@ symbol_register( const char name[] ) } return false; } ); - + return p; } @@ -2968,7 +2968,7 @@ static size_t seek_parent( const symbol_elem_t *e, size_t level ) { size_t program = e->program; const cbl_field_t *field = cbl_field_of(e); - while( program == e->program && level <= field->level ) { + while( program == e->program && level <= field->level ) { if( e->type != SymField ) break; auto f = cbl_field_of(e); if( f->parent == 0 ) break; @@ -2982,7 +2982,7 @@ seek_parent( const symbol_elem_t *e, size_t level ) { * For a group, create new fields and copy members recursively. * Precondition: both fields exist in the symbol table. * Postcondition: return final element copied. - * + * * "The condition-name entries for a particular conditional variable * shall immediately follow the entry describing the item...." */ @@ -2990,12 +2990,12 @@ struct symbol_elem_t * symbol_field_same_as( cbl_field_t *tgt, const cbl_field_t *src ) { if( target_in_src(tgt, src) ) { ERROR_FIELD(tgt, "%s %s may not reference itself as part of %s %s", - tgt->level_str(), tgt->name, src->level_str(), src->name); + tgt->level_str(), tgt->name, src->level_str(), src->name); return NULL; } if( tgt->level == 77 && src->type == FldGroup ) { ERROR_FIELD(tgt, "%s %s TYPE TO %s must be an elementary item", - tgt->level_str(), tgt->name, src->name); + tgt->level_str(), tgt->name, src->name); return NULL; } auto last_elem = symbol_at(field_index(tgt)); @@ -3007,8 +3007,8 @@ symbol_field_same_as( cbl_field_t *tgt, const cbl_field_t *src ) { symbol_elem_t *eog = symbol_at_impl(end_of_group(isrc), true); if( src->type != FldGroup ) { - // For scalar, check for Level 88, which if extant must follow immediately. - eog = std::find_if( bog + 1, + // For scalar, check for Level 88, which if extant must follow immediately. + eog = std::find_if( bog + 1, symbols_end(), []( const auto& elem ) { if( elem.type == SymField ) { @@ -3017,7 +3017,7 @@ symbol_field_same_as( cbl_field_t *tgt, const cbl_field_t *src ) { } return true; } ); - } + } cbl_field_t dup = { .parent = field_index(tgt), .line = tgt->line }; @@ -3108,7 +3108,7 @@ is_numeric_constant( const char name[] ) { } #if 0 - auto isym = + auto isym = auto e = symbol_field( current_program_index(), 0, name ); if( !e ) return NULL; auto field = cbl_field_of(e); @@ -3326,7 +3326,7 @@ static cbl_field_t * new_temporary_impl( enum cbl_field_type_t type ) { extern int yylineno; - static int nstack, nliteral; + static int nstack, nliteral; static const struct cbl_field_t empty_alpha = { 0, FldAlphanumeric, FldInvalid, intermediate_e, 0, 0, 0, nonarray, 0, "", @@ -3375,12 +3375,12 @@ new_temporary_impl( enum cbl_field_type_t type ) snprintf(f->name, sizeof(f->name), "_literal%d",++nliteral); } else { snprintf(f->name, sizeof(f->name), "_stack%d",++nstack); - + if( getenv("symbol_temporaries_free") ) { dbgmsg("%s: %s, %s", __func__, f->name, 3 + cbl_field_type_str(f->type)); } } - + return f; } @@ -3421,7 +3421,7 @@ new_literal_add( const char initial[], uint32_t len, enum cbl_field_attr_t attr } static size_t literal_count = 1; - sprintf(field->name, + sprintf(field->name, "%s%c_%zd", "_literal", field->type == FldLiteralA ? 'a' : 'n', @@ -3460,14 +3460,14 @@ void temporaries_t::dump() const { char *output; extern int yylineno; - + asprintf(&output, "%4d: %zu Literals", yylineno, literals.size()); for( const auto& elem : used ) { if( ! elem.second.empty() ) { char *so_far = output; asprintf(&output, "%s, %zu %s", - so_far, - elem.second.size(), + so_far, + elem.second.size(), 3 + cbl_field_type_str(elem.first)); free(so_far); } @@ -3499,11 +3499,11 @@ cbl_field_t * temporaries_t::reuse( cbl_field_type_t type ) { //// DUBNER is defeating reuse as part of investigating problems with recursion return NULL; -//// - +//// + auto& fields = freed[type]; cbl_field_t *field; - + if( fields.empty() ) { return NULL; } else { @@ -3511,7 +3511,7 @@ temporaries_t::reuse( cbl_field_type_t type ) { field = *p; fields.erase(p); } - + return add(field); } @@ -3523,7 +3523,7 @@ temporaries_t::acquire( cbl_field_type_t type ) { field = new_temporary_impl(type); add(field); } - return parser_symbol_add2(field); // notify of reuse + return parser_symbol_add2(field); // notify of reuse } void @@ -3628,14 +3628,14 @@ cbl_field_t::is_ascii() const { /* * Convert an input source-code string literal (or VALUE) to internal encoding. - * - * Input encoding initially defaults to UTF-8, regardless of locale(7), + * + * Input encoding initially defaults to UTF-8, regardless of locale(7), * for two reasons: * 1) The source code might not match the locale - * 2) The assumption is easily disproved with most input. That is, - * input values above 0x7F will rarely look like UFT-8 unless + * 2) The assumption is easily disproved with most input. That is, + * input values above 0x7F will rarely look like UFT-8 unless * they actually are UTF-8. - * + * * If conversion from UTF-8 fails, the compiler's locale is examined * next. If it is C, it is ignored, else it is tried. If that fails, * the input is assumed to be encoded as CP1252. @@ -3651,7 +3651,7 @@ static const char * guess_encoding() { static const char *fromcode; - if( ! fromcode ) { + if( ! fromcode ) { return fromcode = os_locale.assumed; } @@ -3672,9 +3672,9 @@ cbl_field_t::internalize() { static iconv_t cd = iconv_open(tocode, fromcode); static const size_t noconv = size_t(-1); - // Sat Mar 16 11:45:08 2024: require temporary environment for testing + // Sat Mar 16 11:45:08 2024: require temporary environment for testing if( getenv( "INTERNALIZE_NO") ) return data.initial; - + bool using_assumed = fromcode == os_locale.assumed; if( fromcode == tocode || has_attr(hex_encoded_e) ) { @@ -3683,14 +3683,14 @@ cbl_field_t::internalize() { if( is_ascii() ) return data.initial; assert(data.capacity > 0); - + char output[data.capacity + 2], *out = output; char *in = const_cast<char*>(data.initial); size_t n, inbytesleft = data.capacity, outbytesleft = sizeof(output); if( !is_literal(this) && inbytesleft < strlen(data.initial) ) { inbytesleft = strlen(data.initial); } - + assert(fromcode != tocode); while( (n = iconv( cd, &in, &inbytesleft, &out, &outbytesleft)) == noconv ) { @@ -3711,13 +3711,13 @@ cbl_field_t::internalize() { if( 0 < inbytesleft ) { // data.capacity + inbytesleft is not correct if the remaining portion has - // multibyte characters. But the fact reamins that the VALUE is too big. + // multibyte characters. But the fact reamins that the VALUE is too big. ERROR_FIELD(this, "%s %s VALUE '%s' requires %zu bytes for size %u", - cbl_field_t::level_str(level), name, data.initial, - data.capacity + inbytesleft, data.capacity ); + cbl_field_t::level_str(level), name, data.initial, + data.capacity + inbytesleft, data.capacity ); } - // Replace data.initial only if iconv output differs. + // Replace data.initial only if iconv output differs. if( 0 != memcmp(data.initial, output, out - output) ) { assert(out <= output + data.capacity); @@ -3737,14 +3737,14 @@ cbl_field_t::internalize() { int len = int(out - output); char *mem = static_cast<char*>( xcalloc(1, sizeof(output)) ); - // Set the new memory to all blanks, tacking a '!' on the end. + // Set the new memory to all blanks, tacking a '!' on the end. memset(mem, 0x20, sizeof(output) - 1); mem[ sizeof(output) - 2] = '!'; if( is_literal(this) ) { - data.capacity = len; // trailing '!' will be overwritten + data.capacity = len; // trailing '!' will be overwritten } - + memcpy(mem, output, len); // copy only as much as iconv converted free(const_cast<char*>(data.initial)); @@ -3762,7 +3762,7 @@ cbl_field_t::internalize() { } } - + return data.initial; } @@ -3963,32 +3963,32 @@ symbol_label_add( size_t program, cbl_label_t *input ) bool symbol_label_section_exists( size_t program ) { auto pblob = std::find_if( symbols_begin(program), symbols_end(), - []( const auto& sym ) { - if( sym.type == SymField ) { - auto& f( sym.elem.field ); - return f.type == FldBlob; - } - return false; - } ); + []( const auto& sym ) { + if( sym.type == SymField ) { + auto& f( sym.elem.field ); + return f.type == FldBlob; + } + return false; + } ); if( pblob == symbols_end() ) return true; // Section name not required bool has_section = std::any_of( ++pblob, symbols_end(), - []( const auto& sym ) { - if( sym.type == SymLabel ) { - auto& L(sym.elem.label); - if( L.type == LblSection ) { - if( L.name[0] != '_' ) { // not implicit - return true; // Section name exists - } - } - } - return false; - } ); + []( const auto& sym ) { + if( sym.type == SymLabel ) { + auto& L(sym.elem.label); + if( L.type == LblSection ) { + if( L.name[0] != '_' ) { // not implicit + return true; // Section name exists + } + } + } + return false; + } ); if( yydebug && ! has_section ) { symbols_dump(program, true); } // Return true if no Declaratives, because the (non-)requirement is met. - // Return false if Declaratives exist, because no Section name was found. + // Return false if Declaratives exist, because no Section name was found. return has_section; } @@ -4545,7 +4545,7 @@ cbl_key_t( const cbl_occurs_key_t& that ) void cbl_occurs_t::key_alloc( bool ascending ) { - auto nbytes = sizeof(keys[0]) * (nkey + 1); + auto nbytes = sizeof(keys[0]) * (nkey + 1); cbl_occurs_key_t key = { ascending, cbl_field_list_t() }; keys = static_cast<cbl_occurs_key_t *>(xrealloc(keys, nbytes)); @@ -4602,9 +4602,9 @@ cbl_occurs_t::subscript_ok( const cbl_field_t *subscript ) const { if( !is_literal(subscript) ) { return true; // Cannot check non-literals, so, OK. } - // It must be a number. - if( subscript->type != FldLiteralN ) return false; - + // It must be a number. + if( subscript->type != FldLiteralN ) return false; + auto sub = subscript->data.value; if( sub < 1 || sub != size_t(sub) ) { @@ -4775,8 +4775,8 @@ cbl_file_key_t::deforward( size_t ifile ) { } if( ! (is_numeric(field) && 0 == field->data.rdigits) ) { ERROR_FIELD(field, "line %d: RELATIVE file %s key %s " - "must be integer type", - file->line, file->name, field->name); + "must be integer type", + file->line, file->name, field->name); return ifield; } return ifield; diff --git a/gcc/cobol/symfind.cc b/gcc/cobol/symfind.cc index 0665b9253dfbc9146e0c49c65f13e9a1fff1f6fc..f9dc78731a30bfdfd3d273d010eb43a131b12c86 100644 --- a/gcc/cobol/symfind.cc +++ b/gcc/cobol/symfind.cc @@ -97,7 +97,7 @@ static field_keymap_t symbol_map2; void update_symbol_map2( const symbol_elem_t *e ) { auto field = cbl_field_of(e); - + if( ! field->is_typedef() ) { switch( field->type ) { case FldForward: @@ -151,7 +151,7 @@ dump_symbol_map2( const field_key_t& key, const std::list<size_t>& candidates ) } dbgmsg( "%s:%d: %3zu %s {%s}", __func__, __LINE__, - key.program, key.name, fields ); + key.program, key.name, fields ); free(fields); } @@ -506,7 +506,7 @@ symbol_match2( size_t program, } free(ancestry); } - + return fields; } @@ -533,7 +533,7 @@ symbol_match( size_t program, std::list<const char *> names ) { auto inserted = output.insert(*p); if( ! inserted.second ) { yyerror("%s is not a unique reference", key.name); - } + } } return output; } @@ -553,11 +553,11 @@ symbol_typedef( size_t program, std::list<const char *> names ) { static const symbol_elem_t * symbol_field_alias_01; -const symbol_elem_t * +const symbol_elem_t * symbol_field_alias_begin() { return symbol_field_alias_01 = symbol_field_current_record(); } -void +void symbol_field_alias_end() { symbol_field_alias_01 = NULL; } diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc index 52d78c98f39f336a3a1d24e6e4c3036838d1bebd..7b1328107d750b164676a6fcbb9967bfa50c7219 100644 --- a/gcc/cobol/util.cc +++ b/gcc/cobol/util.cc @@ -301,13 +301,13 @@ is_numeric_edited( const char picture[] ) { break; default: numed_message = xasprintf("invalid PICTURE character " - "'%c' at offset %zu in '%s'", - *p, p - picture, picture); + "'%c' at offset %zu in '%s'", + *p, p - picture, picture); break; } dbgmsg( "%s: no, because '%c' at %.*s<-- in '%s'", - __func__, *p, int(p - picture) + 1, picture, picture ); + __func__, *p, int(p - picture) + 1, picture, picture ); return false; } @@ -622,7 +622,7 @@ symbol_field_type_update( cbl_field_t *field, // type matches itself if( field->type == candidate ) { - if( is_usage ) field->usage = candidate; + if( is_usage ) field->usage = candidate; return true; } if( is_usage && field->usage == candidate ) return true; @@ -645,7 +645,7 @@ symbol_field_type_update( cbl_field_t *field, assert(field->type != candidate && is_elementary(candidate)); /* - * Concrete usage candidate. Update usage first (if USAGE clause), then type. + * Concrete usage candidate. Update usage first (if USAGE clause), then type. */ if( is_usage ) { switch(field->type) { @@ -682,7 +682,7 @@ symbol_field_type_update( cbl_field_t *field, if( ! (dialect_mf() && field->has_attr(all_x_e)) ) { return false; } - __attribute__((fallthrough)); + __attribute__((fallthrough)); case FldFloat: case FldNumericBin5: case FldNumericBinary: @@ -1072,7 +1072,7 @@ valid_move( const struct cbl_field_t *tgt, const struct cbl_field_t *src ) /* Needs C++11 */ static_assert(sizeof(matrix[0]) == COUNT_OF(matrix[0]), "matrix should be square"); - + for( const cbl_field_t *args[] = {tgt, src}, **p=args; p < args + COUNT_OF(args); p++ ) { auto& f(**p); @@ -1090,12 +1090,12 @@ valid_move( const struct cbl_field_t *tgt, const struct cbl_field_t *src ) default: if( sizeof(matrix[0]) < f.type ) { cbl_internal_error("logic error: MOVE %s %s invalid type:", - cbl_field_type_str(f.type), f.name); + cbl_field_type_str(f.type), f.name); } break; } } - + assert(tgt->type < sizeof(matrix[0])); assert(src->type < sizeof(matrix[0])); @@ -1115,7 +1115,7 @@ valid_move( const struct cbl_field_t *tgt, const struct cbl_field_t *src ) { case 0: if( src->type == FldLiteralA && is_numericish(tgt) && !is_literal(tgt) ) { - // Allow if input string is an integer. + // Allow if input string is an integer. const char *p = src->data.initial, *pend = p + src->data.capacity; if( p[0] == '+' || p[0] == '-' ) p++; retval = std::all_of( p, pend, isdigit ); @@ -1143,7 +1143,7 @@ valid_move( const struct cbl_field_t *tgt, const struct cbl_field_t *src ) retval = !src_alpha; break; default: - dbgmsg("%s:%d: matrix at %s, %s is %d", __func__, __LINE__, + dbgmsg("%s:%d: matrix at %s, %s is %d", __func__, __LINE__, cbl_field_type_str(src->type), cbl_field_type_str(tgt->type), matrix[src->type][tgt->type]); assert(false); @@ -1157,11 +1157,11 @@ valid_move( const struct cbl_field_t *tgt, const struct cbl_field_t *src ) } if( yydebug && getenv(__func__) ) { - dbgmsg("%s:%d: ok to move %s to %s (0x%02x)", __func__, __LINE__, + dbgmsg("%s:%d: ok to move %s to %s (0x%02x)", __func__, __LINE__, cbl_field_type_str(src->type), cbl_field_type_str(tgt->type), retval); } - + return retval; } @@ -1741,7 +1741,7 @@ date_time_fmt( const char input[] ) { regex_t reg; char type; char pattern[256]; } fmts[] = { { regex_t(), 'D', "^((" DATE_FMT_B "T" TIME_FMT_B ")|(" - DATE_FMT_E "T" TIME_FMT_E "))$" }, + DATE_FMT_E "T" TIME_FMT_E "))$" }, { regex_t(), 'd', "^(" DATE_FMT_B "|" DATE_FMT_E ")$" }, { regex_t(), 't', "^(" TIME_FMT_B "|" TIME_FMT_E ")$" }, }; @@ -1784,9 +1784,9 @@ struct input_file_t { int lineno; const char *name; const line_map *lines; - + input_file_t( const char *name, ino_t inode, - int lineno=1, const line_map *lines = NULL ) + int lineno=1, const line_map *lines = NULL ) : inode(inode), lineno(lineno), name(name), lines(lines) { if( inode == 0 ) inode_set(); @@ -1820,14 +1820,14 @@ class unique_stack : public std::stack<input_file_t> if( n > 1 ) { char *wd = get_current_dir_name(); if( wd ) { - dbgmsg( "depth line copybook filename\n" - "----- ---- --------" - "----------------------------------------"); - for( const auto& v : c ) { - dbgmsg( " %4zu %4d %s", c.size() - --n, v.lineno, no_wd(wd, v.name) ); - } + dbgmsg( "depth line copybook filename\n" + "----- ---- --------" + "----------------------------------------"); + for( const auto& v : c ) { + dbgmsg( " %4zu %4d %s", c.size() - --n, v.lineno, no_wd(wd, v.name) ); + } } else { - dbgmsg("unable to get current working directory: %m"); + dbgmsg("unable to get current working directory: %m"); } free(wd); } @@ -1851,7 +1851,7 @@ static const unsigned int sysp = 0; // not a C header file, cf. line-map.h * Maintain a stack of input filenames. Ensure the files are unique (by * inode), to prevent copybook cycles. Before pushing a new name, Record the * line number that was is current for the current name, so that it can be - * restored when the usurper is popped. + * restored when the usurper is popped. * * Both the file-reader (lexio) and the scanner use this stack. Lexio uses it * to enforce uniqueness, and the scanner to maintain line numbers. @@ -1869,7 +1869,7 @@ bool cobol_filename( const char *name, ino_t inode ) { inode = p->second; assert(inode != 0); } - linemap_add(line_table, LC_ENTER, sysp, name, 1); + linemap_add(line_table, LC_ENTER, sysp, name, 1); input_filename_vestige = name; bool pushed = input_filenames.push( input_file_t(name, inode, 1, lines) ); input_filenames.top().lineno = yylineno = 1; @@ -1902,7 +1902,7 @@ cobol_filename_restore() { const input_file_t& top( input_filenames.top() ); old_filenames[top.name] = top.inode; input_filename_vestige = top.name; - + input_filenames.pop(); if( input_filenames.empty() ) return NULL; @@ -1948,7 +1948,7 @@ verify_format( const char gmsgid[] ) { static int status = regcomp( &re, pattern, cflags ); static char errbuf[80]; - + if( status != 0 ) { int n = regerror(status, &re, errbuf, sizeof(errbuf)); @@ -1959,7 +1959,7 @@ verify_format( const char gmsgid[] ) { gcc_assert(status == 0); regmatch_t rm[30]; - + if( REG_NOMATCH != regexec(&re, gmsgid, COUNT_OF(rm), rm, 0) ){ fprintf(stderr, "bad diagnositic format: '%s'\n", gmsgid); } @@ -1978,7 +1978,7 @@ ydferror( const char gmsgid[], ... ) { va_start (ap, gmsgid); rich_location richloc (line_table, token_location); bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, - gmsgid, &ap, DK_ERROR); + gmsgid, &ap, DK_ERROR); va_end (ap); } @@ -1996,7 +1996,7 @@ class temp_loc_t : protected YYLTYPE { public: temp_loc_t() : orig(token_location) { if( yychar < 3 ) return; - + gcc_location_set(yylloc); // use lookahead location } temp_loc_t( const YYLTYPE& loc) : orig(token_location) { @@ -2004,8 +2004,8 @@ class temp_loc_t : protected YYLTYPE { } temp_loc_t( const YDFLTYPE& loc) : orig(token_location) { YYLTYPE lloc = { - loc.first_line, loc.first_column, - loc.last_line, loc.last_column }; + loc.first_line, loc.first_column, + loc.last_line, loc.last_column }; gcc_location_set(lloc); } ~temp_loc_t() { @@ -2069,7 +2069,7 @@ yyerror( const char gmsgid[], ... ) { va_start (ap, gmsgid); rich_location richloc (line_table, token_location); bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, - gmsgid, &ap, DK_ERROR); + gmsgid, &ap, DK_ERROR); va_end (ap); global_dc->end_group(); } @@ -2081,7 +2081,7 @@ yywarn( const char gmsgid[], ... ) { va_list ap; va_start (ap, gmsgid); auto ret = emit_diagnostic_valist( DK_WARNING, token_location, - option_id, gmsgid, &ap ); + option_id, gmsgid, &ap ); va_end (ap); return ret; } @@ -2118,7 +2118,7 @@ cobol_fileline_set( const char line[] ) { static const int cflags = REG_EXTENDED | REG_ICASE; static regex_t re, *preg = NULL; - int erc; + int erc; regmatch_t pmatch[4]; if( !preg ) { @@ -2138,19 +2138,19 @@ cobol_fileline_set( const char line[] ) { error_msg(yylloc, "invalid #line directive: %s", line ); return line; } - + const char *line_str = xstrndup(line + pmatch[1].rm_so, matched_length(pmatch[1])), *filename = xstrndup(line + pmatch[2].rm_so, matched_length(pmatch[2])); int fileline; - + if( 1 != sscanf(line_str, "%d", &fileline) ) yywarn("could not parse line number %s from #line directive", line_str); - + input_file_t input_file( filename, ino_t(0), fileline ); // constructor sets inode - if( getenv(__func__) ) return filename; // ignore #line directive - + if( getenv(__func__) ) return filename; // ignore #line directive + if( input_filenames.empty() ) { input_file.lines = linemap_add(line_table, LC_ENTER, sysp, filename, 1); input_filenames.push(input_file); @@ -2159,7 +2159,7 @@ cobol_fileline_set( const char line[] ) { input_file_t& file = input_filenames.top(); file = input_file; yylineno = file.lineno; - + return file.name; } @@ -2190,7 +2190,7 @@ parse_file( const char filename[] ) parser_enter_file(filename); timespec_t start; - + int erc = yyparse(); timespec_t finish;