mirror of git://gcc.gnu.org/git/gcc.git
6 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
![]() |
54e4f75b7d |
cobol: Eliminate cppcheck warnings for libgcobol [PR119323]
I configured and ran cppcheck-2.17.0 with this config file: <?xml version="1.0"?> <def format="2"> <define name="HOST_SIZE_T_PRINT_UNSIGNED" value=""%ld""/> <define name="GCC_PRISZ" value=""z""/> <define name="YYLTYPE" value="struct {int first_line; int first_column; int last_line; int last_column;}"/> <define name="__FLT128_MANT_DIG__" value="113"/> <define name="__FLT128_MIN_EXP__" value="-16381"/> </def> and this command line cppcheck --inline-suppr --enable=all --force --language=c++ --library=$CFG \ --check-level=exhaustive \ --disable=unusedFunction \ --disable=missingInclude \ $(cat $FILES) > $RESULT 2>&1 $FILES was all of the .cc files in libgcobol. The result was many hundreds of warnings. The vast bulk of them were recommendations for declaring variables as const, recommendations for changing C-style casts to C++ casts, cheery notes about shadowed variables, and complaints that malloc() results weren't being checked for errors. Two and a half days of applied OCD on my part has reduced the number of warnings down to zero. libgcobol/ChangeLog: PR cobol/119323 * charmaps.cc (__gg__raw_to_ascii): Eliminate cppcheck warnings. (__gg__raw_to_ebcdic): Likewise. (__gg__ebcdic_to_console): Likewise. (__gg__console_to_ascii): Likewise. (__gg__console_to_ebcdic): Likewise. * common-defs.h (struct cbl_declarative_t): Likewise. * gfileio.cc (get_filename): Likewise. (max_value): Likewise. (relative_file_delete_varying): Likewise. (relative_file_delete): Likewise. (read_an_indexed_record): Likewise. (position_state_restore): Likewise. (indexed_file_delete): Likewise. (indexed_file_start): Likewise. (sequential_file_rewrite): Likewise. (relative_file_write_varying): Likewise. (relative_file_write): Likewise. (sequential_file_write): Likewise. (indexed_file_write): Likewise. (__io__file_write): Likewise. (line_sequential_file_read): Likewise. (indexed_file_read): Likewise. (file_indexed_open): Likewise. (__gg__file_reopen): Likewise. * gmath.cc (conditional_stash): Likewise. (__gg__pow): Likewise. (multiply_int256_by_int64): Likewise. (add_int256_to_int256): Likewise. (divide_int256_by_int64): Likewise. (squeeze_int256): Likewise. (get_int256_from_qualified_field): Likewise. (__gg__add_fixed_phase1): Likewise. (__gg__addf1_fixed_phase2): Likewise. (__gg__fixed_phase2_assign_to_c): Likewise. (__gg__add_float_phase1): Likewise. (__gg__addf1_float_phase2): Likewise. (__gg__float_phase2_assign_to_c): Likewise. (__gg__addf3): Likewise. (__gg__subtractf1_fixed_phase2): Likewise. (__gg__subtractf2_fixed_phase1): Likewise. (__gg__subtractf1_float_phase2): Likewise. (__gg__subtractf2_float_phase1): Likewise. (__gg__subtractf3): Likewise. (__gg__multiplyf1_phase1): Likewise. (multiply_int128_by_int128): Likewise. (__gg__multiplyf1_phase2): Likewise. (__gg__multiplyf2): Likewise. (shift_in_place128): Likewise. (divide_int128_by_int128): Likewise. (__gg__dividef1_phase2): Likewise. (__gg__dividef23): Likewise. (__gg__dividef45): Likewise. * intrinsic.cc (struct input_state): Likewise. (get_value_as_double_from_qualified_field): Likewise. (kahan_summation): Likewise. (variance): Likewise. (get_all_time): Likewise. (populate_ctm_from_date): Likewise. (populate_ctm_from_time): Likewise. (ftime_replace): Likewise. (__gg__abs): Likewise. (__gg__acos): Likewise. (__gg__annuity): Likewise. (__gg__asin): Likewise. (__gg__atan): Likewise. (__gg__byte_length): Likewise. (__gg__char): Likewise. (__gg__combined_datetime): Likewise. (__gg__cos): Likewise. (__gg__date_of_integer): Likewise. (__gg__date_to_yyyymmdd): Likewise. (__gg__day_of_integer): Likewise. (__gg__day_to_yyyyddd): Likewise. (__gg__exp): Likewise. (__gg__exp10): Likewise. (__gg__factorial): Likewise. (__gg__formatted_current_date): Likewise. (__gg__formatted_date): Likewise. (__gg__formatted_datetime): Likewise. (__gg__formatted_time): Likewise. (__gg__integer): Likewise. (__gg__integer_of_date): Likewise. (__gg__integer_of_day): Likewise. (__gg__integer_part): Likewise. (__gg__fraction_part): Likewise. (__gg__log): Likewise. (__gg__log10): Likewise. (__gg__max): Likewise. (__gg__lower_case): Likewise. (__gg__median): Likewise. (__gg__min): Likewise. (numval): Likewise. (numval_c): Likewise. (__gg__numval): Likewise. (__gg__test_numval): Likewise. (__gg__numval_c): Likewise. (__gg__test_numval_c): Likewise. (__gg__ord): Likewise. (__gg__rem): Likewise. (__gg__trim): Likewise. (__gg__random): Likewise. (__gg__reverse): Likewise. (__gg__sign): Likewise. (__gg__sin): Likewise. (__gg__sqrt): Likewise. (__gg__tan): Likewise. (__gg__test_date_yyyymmdd): Likewise. (__gg__test_day_yyyyddd): Likewise. (__gg__upper_case): Likewise. (__gg__year_to_yyyy): Likewise. (gets_int): Likewise. (gets_year): Likewise. (gets_month): Likewise. (gets_day): Likewise. (gets_day_of_week): Likewise. (gets_day_of_year): Likewise. (gets_week): Likewise. (gets_hours): Likewise. (gets_minutes): Likewise. (gets_seconds): Likewise. (gets_nanoseconds): Likewise. (fill_cobol_tm): Likewise. (__gg__test_formatted_datetime): Likewise. (__gg__integer_of_formatted_date): Likewise. (__gg__seconds_from_formatted_time): Likewise. (__gg__hex_of): Likewise. (__gg__highest_algebraic): Likewise. (__gg__lowest_algebraic): Likewise. (floating_format_tester): Likewise. (__gg__numval_f): Likewise. (__gg__test_numval_f): Likewise. (ismatch): Likewise. (iscasematch): Likewise. (strstr): Likewise. (strcasestr): Likewise. (strlaststr): Likewise. (strcaselaststr): Likewise. (__gg__substitute): Likewise. (__gg__locale_compare): Likewise. (__gg__locale_date): Likewise. (__gg__locale_time): Likewise. (__gg__locale_time_from_seconds): Likewise. * libgcobol.cc (class ec_status_t): Likewise. (__gg__set_truncation_mode): Likewise. (malloc): Likewise. (__gg__mabort): Likewise. (__gg__resize_int_p): Likewise. (__gg__resize_treeplet): Likewise. (var_is_refmod): Likewise. (value_is_too_big): Likewise. (__gg__string_to_alpha_edited_ascii): Likewise. (int128_to_field): Likewise. (edited_to_binary): Likewise. (get_binary_value_local): Likewise. (__gg__get_date_yymmdd): Likewise. (__gg__get_date_yyyymmdd): Likewise. (__gg__get_date_yyddd): Likewise. (__gg__get_yyyyddd): Likewise. (__gg__get_date_dow): Likewise. (get_scaled_rdigits): Likewise. (format_for_display_internal): Likewise. (compare_88): Likewise. (get_float128): Likewise. (compare_field_class): Likewise. (compare_strings): Likewise. (__gg__compare_2): Likewise. (__gg__sort_table): Likewise. (init_var_both): Likewise. (alpha_to_alpha_move_from_location): Likewise. (alpha_to_alpha_move): Likewise. (__gg__move): Likewise. (__gg__move_literala): Likewise. (__gg__sort_workfile): Likewise. (__gg__merge_files): Likewise. (normalize_id): Likewise. (inspect_backward_format_1): Likewise. (__gg__inspect_format_1): Likewise. (inspect_backward_format_2): Likewise. (__gg__inspect_format_2): Likewise. (__gg__inspect_format_4): Likewise. (move_string): Likewise. (__gg__string): Likewise. (display_both): Likewise. (__gg__display_string): Likewise. (__gg__accept): Likewise. (__gg__binary_value_from_qualified_field): Likewise. (__gg__float128_from_qualified_field): Likewise. (float128_to_int128): Likewise. (float128_to_location): Likewise. (__gg__set_initial_switch_value): Likewise. (is_numeric_display_numeric): Likewise. (is_packed_numeric): Likewise. (is_alpha_a_number): Likewise. (__gg__classify): Likewise. (__gg__accept_envar): Likewise. (__gg__set_envar): Likewise. (command_line_plan_b): Likewise. (__gg__get_command_line): Likewise. (__gg__set_pointer): Likewise. (__gg__ascii_to_internal_field): Likewise. (__gg__internal_to_console_in_place): Likewise. (__gg__routine_to_call): Likewise. (__gg__fetch_call_by_value_value): Likewise. (__gg__assign_value_from_stack): Likewise. (__gg__literaln_alpha_compare): Likewise. (string_in): Likewise. (__gg__unstring): Likewise. (local_ec_type_of): Likewise. (struct exception_descr_t): Likewise. (struct cbl_exception_t): Likewise. (cbl_enabled_exception_t: Likewise.: Likewise.dump): Likewise. (__gg__match_exception): Likewise. (__gg__float128_from_location): Likewise. (__gg__integer_from_float128): Likewise. (__gg__set_exception_file): Likewise. (__gg__func_exception_file): Likewise. (__gg__set_exception_code): Likewise. (__gg__is_float_infinite): Likewise. (__gg__float32_from_128): Likewise. (__gg__float32_from_64): Likewise. (__gg__float64_from_128): Likewise. (__gg__copy_as_big_endian): Likewise. (__gg__get_figconst_data): Likewise. (find_in_dirs): Likewise. (__gg__function_handle_from_cobpath): Likewise. (__gg__just_mangle_name): Likewise. (__gg__function_handle_from_literal): Likewise. (__gg__function_handle_from_name): Likewise. (__gg__mirror_range): Likewise. (__gg__deallocate): Likewise. (__gg__allocate): Likewise. (__gg__module_name): Likewise. (__gg__set_env_name): Likewise. (__gg__set_env_value): Likewise. * libgcobol.h (__gg__mabort): Likewise. (massert): Likewise. (PTRCAST): Likewise. (__gg__float128_from_location): Likewise. (__gg__set_exception_file): Likewise. (__gg__binary_value_from_qualified_field): Likewise. (__gg__float128_from_qualified_field): Likewise. * valconv.cc (__gg__realloc_if_necessary): Likewise. (__gg__alphabet_create): Likewise. (__gg__string_to_numeric_edited): Likewise. (__gg__string_to_alpha_edited): Likewise. * valconv.h: Likewise. |
|
![]() |
fba34a0cc5 |
cobol: Multiple PRs; formatting; exception processing.
The PRs mentined here have either been previously fixed, or are fixed by this commit. gcc/cobol/ChangeLog: PR cobol/119770 PR cobol/119772 PR cobol/119790 PR cobol/119771 PR cobol/119810 PR cobol/119335 PR cobol/119632 * cdf-copy.cc (GLOB_BRACE): Eliminate <glob.h>. * cdfval.h (_CDF_VAL_H_): Switch to C++ headers. * copybook.h (class copybook_elem_t): Eliminate <glob.h>. (class copybook_t): Likewise. * gcobc: Numerous changes to improve utility. * gcobol.1: Correct names in the list of functions. * genapi.cc (compare_binary_binary): Use has_attr() function. * lexio.cc (cdftext::lex_open): Typo; filename logic. (cdftext::process_file): Filename logic. * parse.y: Numerous parsing changes. * parse_ante.h (new_alphanumeric): C++ includes; changes to temporaries. (new_tempnumeric): Likewise. (new_tempnumeric_float): Likewise. (set_real_from_capacity): Created. * scan.l: Use yy_pop_state(). * scan_ante.h (typed_name): Find figconst from data.initial. * symbols.cc (symbol_valid_udf_args): Eliminate. (symbols_update): figconst processing. (new_temporary_impl): For functions, set .initial to function name. (temporaries_t::acquire): Likewise. (new_alphanumeric): Likewise. (new_temporary): Likewise. * symbols.h (_SYMBOLS_H_): Use C++ includes. (cbl_figconst_tok): Change handling of figconst. (cbl_figconst_field_of): Change handling of figconst. (symbol_valid_udf_args): Eliminate. * symfind.cc (symbol_match2): Change declaration. (symbol_match): Change declaration. libgcobol/ChangeLog: * charmaps.cc: Switch to C++ includes. * common-defs.h: Likewise. * constants.cc: Likewise. * ec.h: Remove #include <assert.h>. * gcobolio.h (GCOBOLIO_H_): Switch to C++ includes. * gfileio.cc: Likewise. * gmath.cc: Likewise. * intrinsic.cc: Comment formatting; C++ includes. * io.cc: C++ includes. * libgcobol.cc: (__gg__stash_exceptions): Eliminate. * valconv.cc: Switch to C++ includes. Co-Authored-By: James K. Lowden <jklowden@cobolworx.com> |
|
![]() |
c4d0f4c499 |
cobol: Rewrite exception handling. Partially refactor subscript/refmod calculations.
This commit includes changes to exception handling, and changes to the calculations for offsets and lengths when processing subscripted table entries and variables with (from:length) reference modifications. Exception handling in COBOL requires significant amounts of information to be built at compile time and sent to libgcobol.so at run time. The changes here reduce some problems caused by creating structures by the host that are processed by the target, mainly by creating arrays of simple integers rather than by turning a structure into a stream of bytes. Significant changes to the logic of exception handling brings the run-time performance more in line with the ISO specification. The handling of COBOL variables that include tables defined with DEPENDING ON clauses is subtly different when used as sending variables versus when they are receiving variables. This commit folds the very similar refer_offset_source and refer_offset_dest routines into a single refer_offset routine. It also streamlines the refer_length_source and refer_length_dest routines by moving common code into a static refer_length() routine, and having refer_length_source() and refer_length_dest() each call refer_length() with a a type flag. Co-Authored by: James K. Lowden <jklowden@cobolworx.com> Co-Authored by: Robert Dubner <rdubner@symas.com> gcc/cobol/ChangeLog: * cdf.y: Exceptions. * except.cc (cbl_enabled_exception_t::dump): Likewise. (cbl_enabled_exceptions_t::dump): Likewise. (cbl_enabled_exceptions_t::status): Likewise. (cbl_enabled_exceptions_t::encode): Likewise. (cbl_enabled_exceptions_t::turn_on_off): Likewise. (cbl_enabled_exceptions_t::match): Likewise. (declarative_runtime_match): Likewise. Likewise. * exceptg.h (struct cbl_exception_files_t): Likewise. (class exception_turn_t): Likewise. (apply_cdf_turn): Likewise. * genapi.cc (treeplet_fill_source): Use refer_offset(). (function_handle_from_name): Likewise. (parser_initialize_programs): Likewise. (parser_statement_begin): Likewise. (array_of_long_long): Exceptions. (parser_compile_ecs): Exceptions. (parser_compile_dcls): Exceptions. (store_location_stuff): Exceptions. (initialize_variable_internal): Use refer_offset(). (compare_binary_binary): Use refer_offset(). (cobol_compare): Use refer_offset(). (paragraph_label): Formatting. (parser_goto): Use refer_offset(). (parser_perform_times): Likewise. (internal_perform_through_times): Likewise. (parser_enter_file): Exceptions. (psa_FldLiteralN): Add comment. (parser_accept): Use refer_offset(). (parser_accept_command_line): Likewise. (parser_accept_command_line_count): Likewise. (parser_accept_envar): Likewise. (parser_set_envar): Likewise. (parser_display_internal): Likewise. (parser_initialize_table): Likewise. (parser_sleep): Likewise. (parser_allocate): Likewise. (parser_free): Likewise. (parser_division): Likewise. (parser_relop_long): Likewise. (parser_see_stop_run): Likewise. (parser_classify): Likewise. (parser_file_add): Include symbol_table_index in __gg__file_init(). (parser_file_open): Use refer_offset(). (parser_file_write): Move forward declaration of store_location_stuff(). (parser_file_start): Use refer_offset(). (parser_inspect_conv): Likewise: (parser_intrinsic_numval_c): Likewise: (parser_intrinsic_subst): Likewise: (parser_intrinsic_call_1): Likewise: (parser_intrinsic_call_2): Likewise: (parser_intrinsic_call_3): Likewise: (parser_intrinsic_call_4): Likewise: (parser_sort): Likewise: (parser_return_start): Exceptions. (parser_unstring): Use refer_offset(). (create_and_call): Likewise. (parser_set_pointers): Use refer_offset(). (parser_program_hierarchy): Comment. (parser_set_handled): Exceptions; removed. (parser_set_file_number): Exceptions; removed. (stash_exceptions): Exceptions; removed. (parser_exception_prepare): Exceptions; removed. (parser_match_exception): Exceptions; eliminate blob. (parser_check_fatal_exception): Exceptions. (parser_push_exception): Create. (parser_pop_exception): Create. (mh_identical): Use refer_offset(). (mh_source_is_literalN): Likewise. (mh_dest_is_float): Likewise. (mh_numeric_display): Likewise. (mh_little_endian): Likewise. (mh_source_is_group): Likewise. (move_helper): Likewise. (binary_initial_from_float128): Formatting; change error message. (initial_from_float128): Change name to "initial_from_initial" (initial_from_initial): Add one byte to allocation for figconsts. (parser_symbol_add): Use initial_from_initial(). (parser_symbol_add): Eliminate unneeded logic around actually_create... * genapi.h: Exceptions. * genmath.cc (fast_add): Use refer_offset(). (fast_subtract): Likewise. (fast_multiply): Likewise. (fast_divide): Likewise. * genutil.cc: Exceptions; various global definitions. (get_integer_value): Comment. (get_data_offset_dest): Eliminate. (get_data_offset_source): Rename to get_data_offset(). (get_data_offset): Use refer_offset(). (get_binary_value): Likewise; eliminate use of literal_decl_node. (build_array_of_treeplets): Likewise. (build_array_of_fourplets): Likewise. (REFER_CHECK): Comment: (refer_refmod_length): Use get_any_capacity(); use refer_offset; set reflen to integer_one_node. (refer_offset_dest): Change name to refer_offset. (refer_offset): Use get_data_offset(). (refer_size_dest): Change name to refer_size(). (refer_size): Use get_any_capacity(). (refer_offset_source): Use refer_offset(). (refer_size_source): Likewise. (qualified_data_source): Likewise. (qualified_data_dest): Likewise. (qualified_data_location): Likewise. * genutil.h: Exceptions; changes to global declarations. * lexio.cc (likely_nist_file): Added to detect NIST file format. (cdftext::free_form_reference_format): Handle NIST file format. * parse.y: (strip_trailing_zeroes): Added. Changes for exceptions. * parse_ante.h (parse_error_inc): Likewise. (YYLLOC_DEFAULT): Likewise. (static_cast): Likewise. (is_cobol_word): Change to is_cobol_charset. (is_cobol_charset): Refine allowed characters. (require_numeric): Change to require integer. (require_integer): Likewise. (current_enabled_ecs): Exceptions. (is_integer_literal): Change interpretation. (procedure_division_ready): Exceptions. (statement_epilog): Likewise. (statement_begin): Likewise. * show_parse.h: Changes to GCOBOL_SHOW handling. * structs.cc: Add symbol_index to cblc_file_t structure. * symbols.cc (field_str): Repair .initial handling in FldLiteralN. * symbols.h (struct cbl_field_t): Eliminate literal_decl_node. (current_enabled_ecs): Exceptions. * util.cc (cbl_message): Add final newline to error message. (ftoupper): Added. (iso_cobol_word): Add list of ISO reserved words. * util.h (ftoupper): Added. libgcobol/ChangeLog: * charmaps.cc: Add #include <vector>. * common-defs.h (COMMON_DEFS_H_): Add #include <stdio.h>. (enum cbl_file_mode_t): Add file_mode_any_e. (enum file_stmt_t): Created. (cbl_file_mode_str): Add case for file_mode_any_e. (ec_cmp): Exceptions. (struct cbl_enabled_exception_t): Likewise. (struct cbl_declarative_t): Likewise. (class cbl_enabled_exceptions_array_t): Likewise. (class cbl_enabled_exceptions_t): Likewise. (struct cbl_enabled_exceptions_array_t): Likewise. (enabled_exception_match): Likewise. * constants.cc: Add #include <vector>. * exceptl.h (struct cbl_exception_t): Removed. (struct cbl_declarative_t): Removed. (class ec_status_t): Removed. * gcobolio.h: Add symbol_table_index to cblc_file_t. * gfileio.cc: Add #include <vector> (establish_status): Comment. (__io__file_init): Handle symbol_table_index. (__io__file_delete): Set file->prior_op. (__io__file_rewrite): Likewise. (__io__file_read): Likewise. (__io__file_open): Likewise. (__io__file_close): Likewise. * gmath.cc: Include #include <vector>. * intrinsic.cc: Include #include <vector>. * libgcobol.cc: Multiple modifications for exceptions. * valconv.cc: #include <vector>. |
|
![]() |
95f10974a9 |
libgcobol: Allow libgcobol to use libquadmath [PR119244].
Many of the changes are mechanical: 1. 'GCOB_FP128' in place of _Float128. 2. Using FP128_FUNC to represent the spelling of intrinsics. 3. Using GCOB_FP128_LITERAL() to choose the suffix for literals. This allows for: __float128 and 'q' as the suffix when libquadmath is configured. _Float128 / 'f128' when IEC-60559 is available in libc long double / 'l' when long double is ieee753 128b. Add libquadmath to libgcobol.spec and its dependencies where the platform needs it. PR cobol/119244 libgcobol/ChangeLog: * Makefile.am: Add support for libquadmath. * Makefile.in: Regenerate. * acinclude.m4: Add support for libquadmath. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Configure libquadmath support. * gmath.cc: Use GCOB_FP128 to represent the configured 128b floating point type. Use FP128_FUNC to represent the naming of intrinsics in the configure 128b floating point type. Render literals with GCOB_FP128_LITERAL. * intrinsic.cc: Likewise. * libgcobol.cc: Likewise. * libgcobol.h: Likewise. * libgcobol-fp.h: New file. * gfileio.cc: Include libgcobol-fp.h. * libgcobol.spec.in: Add libquadmath configure output. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> |
|
![]() |
ce1cf36199 |
libgcobol: Ensure that config.h is included where needed.
This includes config.h before any other project-related headers or sources so that they properly make use of the values determined by configure. libgcobol/ChangeLog: * gfileio.cc: Include config.h. * gmath.cc: Likewise. * io.cc: Likewise. * libgcobol.cc: Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> |
|
![]() |
a075418727 |
COBOL: libgcobol
libgcobol/ * Makefile.am: New file. * Makefile.in: Autogenerate. * acinclude.m4: Likewise. * aclocal.m4: Likewise. * configure.ac: New file. * configure: Autogenerate. * configure.tgt: New file. * README: New file. * charmaps.cc: New file. * config.h.in: New file. * constants.cc: New file. * gfileio.cc: New file. * gmath.cc: New file. * io.cc: New file. * valconv.cc: New file. * charmaps.h: New file. * common-defs.h: New file. * ec.h: New file. * exceptl.h: New file. * gcobolio.h: New file. * gfileio.h: New file. * gmath.h: New file. * io.h: New file. * libgcobol.h: New file. * valconv.h: New file. * libgcobol.cc: New file. * intrinsic.cc: New file. |