Commit Graph

107 Commits

Author SHA1 Message Date
GCC Administrator
1179ac1fab Daily bump. 2025-09-06 00:20:34 +00:00
Robert Dubner
dc20fa683d cobol: Improved handling of COBOL Special Registers.
COBOL Special Registers (e.g., RETURN-CODE; DEBUG-ITEM) are implemented as
global variables.  These changes define them with the prefix "__ggsr__" in
their variable names so that the GDB-COBOL debugger can identify them.

The creation and handling of such variables has been streamlined with the
introduction of the "register_e" cbl_field_t::attr bit.

gcc/cobol/ChangeLog:

	* genapi.cc (trace1_init): Prepend two internal variables with
	underscore.
	(initialize_variable_internal): Use new register_e attribute.
	(psa_global): Use "__ggsr__" prefix to identify special registers
	(parser_symbol_add): Use new register_e attribute.
	* symbols.cc (cbl_field_attr_str): Likewise.
	(symbol_table_init): Likewise.
	(is_register_field): Eliminated in favor of (attr & register_e).
	* symbols.h (is_register_field): Likewise.

libgcobol/ChangeLog:

	* common-defs.h (enum cbl_field_attr_t): Define register_e.
	* constants.cc (struct cblc_field_t): Define special registers with
	"__ggsr__" prefix.
2025-09-05 11:08:27 -04:00
GCC Administrator
d670769bf6 Daily bump. 2025-08-21 00:20:43 +00:00
Robert Dubner
e78eb2f85b cobol: Eliminate errors that cause valgrind messages.
gcc/cobol/ChangeLog:

	* genutil.cc (get_binary_value): Fix a comment.
	* parse.y: udf_args_valid(): Fix loc calculation.
	* symbols.cc (assert): extend_66_capacity(): Avoid assert(e < e2) in
	-O0 build until symbol_table expansion is fixed.

libgcobol/ChangeLog:

	* libgcobol.cc (format_for_display_internal): Handle NumericDisplay
	properly.
	(compare_88): Fix memory access error.
	(__gg__unstring): Likewise.
2025-08-19 23:29:43 -04:00
GCC Administrator
6520bb9efb Daily bump. 2025-08-14 00:20:55 +00:00
Mark Wielaard
eecff13cdc Regenerate libgcobol/configure
Use autoconf 2.69 to regenerate libgcobol/configure

Fixes: 9992c0a0e1 ("cobol: Bring EBCDIC NumericDisplay variables into IBM compliance.")

libgcobol/ChangeLog:

	* configure: Regenerate.
2025-08-13 17:53:27 +02:00
Robert Dubner
33e26a071f cobol: Implement and use faster __gg__packed_to_binary() routine.
The new routine uses table lookups more effectively, and avoids __int128
arithmetic until necessary.

gcc/cobol/ChangeLog:

	* genutil.cc (get_binary_value): Use the new routine.

libgcobol/ChangeLog:

	* libgcobol.cc (get_binary_value_local): Use the new routine.
	* stringbin.cc (int_from_string): Removed.
	(__gg__packed_to_binary): Implement new routine.
	* stringbin.h (__gg__packed_to_binary): Likewise.
2025-08-13 11:33:41 -04:00
Robert Dubner
67e0490922 cobol: Implement faster zoned decimal to binary conversion.
Replace " value *= 10; value += digit" routines with a new one that does two
digits at a time and avoids __int128 calculations until they are necessary.

These changes also clean up the conversion behavior when a digit is not valid.

gcc/cobol/ChangeLog:

	* genutil.cc (get_binary_value): Use the new routine.

libgcobol/ChangeLog:

	* libgcobol.cc (int128_to_field): Use the new routine.
	(get_binary_value_local): Use the new routine.
	(format_for_display_internal): Formatting.
	(__gg__get_file_descriptor): Likewise.
	* stringbin.cc (string_from_combined): Formatting.
	(packed_from_combined): Likewise.
	(int_from_string): New routine.
	(__gg__numeric_display_to_binary): Likewise.
	* stringbin.h (__gg__numeric_display_to_binary): Likewise.
2025-08-12 22:23:47 -04:00
GCC Administrator
28c0d45201 Daily bump. 2025-08-13 00:19:57 +00:00
Robert Dubner
9992c0a0e1 cobol: Bring EBCDIC NumericDisplay variables into IBM compliance.
The internal representation of Numeric Display (ND) zoned decimal variables
when operating in EBCDIC mode has been brought into compliance with IBM
conventions.  This requires changes to data input, data output, internal
conversion of zoned decimal to binary, and variable assignment.

gcc/cobol/ChangeLog:

	* genapi.cc (compare_binary_binary): Formatting.
	(cobol_compare): Formatting.
	(mh_numeric_display): Rewrite "move ND to ND" algorithm.
	(initial_from_initial): Proper initialization of EBCDIC ND variables.
	* genmath.cc (fast_add): Delete comment.
	* genutil.cc (get_binary_value): Modify for updated EBCDIC.

libgcobol/ChangeLog:

	* common-defs.h (NUMERIC_DISPLAY_SIGN_BIT): New comment; new constant.
	(EBCDIC_MINUS): New constant.
	(EBCDIC_PLUS): Likewise.
	(EBCDIC_ZERO): Likewise.
	(EBCDIC_NINE): Likewise.
	(PACKED_NYBBLE_PLUS): Likewise.
	(PACKED_NYBBLE_MINUS): Likewise.
	(PACKED_NYBBLE_UNSIGNED): Likewise.
	(NUMERIC_DISPLAY_SIGN_BIT_ASCII): Likewise.
	(NUMERIC_DISPLAY_SIGN_BIT_EBCDIC): Likewise.
	(SEPARATE_PLUS): Likewise.
	(SEPARATE_MINUS): Likewise.
	(ZONED_ZERO): Likewise.
	(ZONE_SIGNED_EBCDIC): Likewise.
	* configure: Regenerate.
	* libgcobol.cc (turn_sign_bit_on): Handle new EBCDIC sign convention.
	(turn_sign_bit_off): Likewise.
	(is_sign_bit_on): Likewise.
	(int128_to_field): EBCDIC NumericDisplay conversion.
	(get_binary_value_local): Likewise.
	(format_for_display_internal): Likewise.
	(normalize_id): Likewise.
	(__gg__inspect_format_1): Convert EBCDIC negative numbers to positive.
	* stringbin.cc (packed_from_combined): Quell cppcheck warning.

gcc/testsuite/ChangeLog:

	* cobol.dg/group2/ALLOCATE_Rule_8_OPTION_INITIALIZE_with_figconst.out:
	Change test for updated handling of Numeric Display variables.
2025-08-11 21:22:57 -04:00
GCC Administrator
e5bb389603 Daily bump. 2025-08-11 00:16:52 +00:00
H.J. Lu
59dbef0764 Regenerate configure files
Regenerate configure files after

commit 8a3ad190c1
Author: Ijaz, Abdul B <abdul.b.ijaz@intel.com>
Date:   Sun Aug 10 08:33:30 2025 -0600

    config: Handle dash in library name for AC_LIB_LINKAGEFLAGS_BODY

gcc/

	* configure: Regenerated.

libcpp/

	* configure: Regenerated.

libgcobol/

	* configure: Regenerated.

libstdc++-v3/

	* configure: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-10 08:01:02 -07:00
GCC Administrator
b0940964f1 Daily bump. 2025-08-09 00:19:57 +00:00
Robert Dubner
435e09e05c cobol: Divide-and-conquer conversion from binary to packed-decimal.
The legacy routine for converting a binary integer to a packed-decimal
representaion peeled two digits at a time from the bottom of an _int128 value.
These changes replace that routine with a divide-and-conquer algorithm that
runs about ten times faster.

libgcobol/ChangeLog:

	* libgcobol.cc (int128_to_field): Switch to the new routine.
	* stringbin.cc (packed_from_combined): Implement the new routine.
	(__gg__binary_to_packed): Likewise.
	* stringbin.h (__gg__binary_to_packed): Likewise.
2025-08-08 13:53:59 -04:00
GCC Administrator
030d9dd0f6 Daily bump. 2025-08-08 00:18:50 +00:00
Robert Dubner
c684053fc0 cobol: Improve binary-to-string conversion.
COBOL often requires the conversion of binary integers to string of characters.
These changes replace a naive routine that peels decimal digits from a binary
value one digit at a time, with a divide-and-conquer algorithm that is twice as
fast even for a couple of digits, and is about eight times faster past ten
digits.

Included here are some minor fixes to the lexer and parser.

gcc/cobol/ChangeLog:

	* cbldiag.h (location_dump): Source code formatting.
	* parse.y: error_msg formatting.
	* scan.l: Remove UTF-8 character from regex pattern.
	* scan_ante.h (numstr_of): error_msg formatting.
	* show_parse.h (class ANALYZE): Suppress cppcheck error.
	* util.cc (cbl_field_t::report_invalid_initial_value):
	error_msg formatting.

libgcobol/ChangeLog:

	* Makefile.am: Include new stringbin.cc file.
	* Makefile.in: Regenerated.
	* libgcobol.cc (__gg__power_of_ten): Improve error message.
	(__gg__binary_to_string): Deleted.
	(__gg__binary_to_string_internal): Deleted.
	(int128_to_field): Use new conversion routine.
	(__gg__move): Use new conversion routine.
	* stringbin.cc: New file. Implements new conversion routine.
	* stringbin.h: New file. Likewise.
2025-08-07 16:12:32 -04:00
GCC Administrator
c7798b53bd Daily bump. 2025-07-14 00:16:48 +00:00
Robert Dubner
9b9753718e cobol: Minor changes to genapi.cc to eliminate CPPCHECK warnings.
Several hundred cppcheck warnings were eliminated.

Most of these changes were replacing C-style casts, checking for NULL
pointers, establishing some variables and formal parameters as const,
and moving some variables around to tidy up their scopes.

One memory leak was found and eliminated as a result of the cppcheck.

gcc/cobol/ChangeLog:

	* Make-lang.in: Eliminate the .cc.o override.
	* genapi.cc (level_88_helper): Eliminate cppcheck warning.
	(get_level_88_domain): Likewise.
	(get_class_condition_string): Likewise.
	(parser_call_targets_dump): Likewise.
	(parser_compile_ecs): Likewise.
	(initialize_variable_internal): Likewise.
	(move_tree): Likewise.
	(combined_name): Likewise.
	(assembler_label): Likewise.
	(find_procedure): Likewise.
	(parser_perform): Likewise.
	(parser_perform_times): Likewise.
	(internal_perform_through): Likewise.
	(internal_perform_through_times): Likewise.
	(psa_FldLiteralN): Likewise.
	(psa_FldBlob): Likewise.
	(parser_accept): Likewise.
	(parser_accept_exception): Likewise.
	(parser_accept_exception_end): Likewise.
	(parser_accept_command_line): Likewise.
	(parser_accept_envar): Likewise.
	(parser_display_internal): Likewise.
	(parser_display): Likewise.
	(parser_assign): Likewise.
	(parser_initialize_table): Likewise.
	(parser_arith_error): Likewise.
	(parser_arith_error_end): Likewise.
	(parser_division): Likewise.
	(label_fetch): Likewise.
	(parser_label_label): Likewise.
	(parser_label_goto): Likewise.
	(parser_perform_start): Likewise.
	(parser_perform_conditional): Likewise.
	(parser_perform_conditional_end): Likewise.
	(parser_perform_until): Likewise.
	(parser_file_delete): Likewise.
	(parser_intrinsic_subst): Likewise.
	(create_lsearch_address_pairs): Likewise.
	(parser_bsearch_start): Likewise.
	(is_ascending_key): Likewise.
	(parser_sort): Likewise.
	(parser_file_sort): Likewise.
	(parser_return_start): Likewise.
	(parser_file_merge): Likewise.
	(parser_string_overflow): Likewise.
	(parser_unstring): Likewise.
	(parser_string): Likewise.
	(parser_call_exception): Likewise.
	(create_and_call): Likewise.
	(mh_identical): Likewise.
	(move_helper): Likewise.
	(binary_initial_from_float128): Likewise.
	(initial_from_initial): Likewise.
	(psa_FldLiteralA): Likewise.
	(parser_local_add): Likewise.
	(parser_symbol_add): Likewise.
	* genapi.h (parser_display): Likewise.
	* gengen.cc (gg_call_expr): Explict check for NULL_TREE.
	(gg_call): Likewise.
	* show_parse.h (SHOW_PARSE_LABEL_OK): Likewise.
	(TRACE1_FIELD_VALUE): Likewise.
	(CHECK_FIELD): Likewise.
	(CHECK_FIELD2): Likewise.
	(CHECK_LABEL): Likewise.
	* util.cc (cbl_internal_error): Apply [[noreturn]] attribute.
	* util.h (cbl_internal_error): Likewise.

libgcobol/ChangeLog:

	* common-defs.h (PTRCAST): Moved here from libgcobol.h.
	* libgcobol.h (PTRCAST): Deleted.
2025-07-13 10:05:17 -04:00
GCC Administrator
75111d0594 Daily bump. 2025-07-11 00:19:26 +00:00
James K. Lowden
3f59a1cac7 cobol: Add PUSH and POP to CDF.
Introduce cdf_directives_t class to centralize management of CDF
state. Move existing CDF state variables and functions into the new
class.

gcc/cobol/ChangeLog:

	PR cobol/120765
	* cdf.y: Extend grammar for new CDF syntax, relocate dictionary.
	* cdfval.h (cdf_dictionary): Use new CDF dictionary.
	* dts.h: Remove useless assignment, note incorrect behavior.
	* except.cc: Remove obsolete EC state.
	* gcobol.1: Document CDF in its own section.
	* genapi.cc (parser_statement_begin): Use new EC state function.
	(parser_file_merge): Same.
	(parser_check_fatal_exception): Same.
	* genutil.cc (get_and_check_refstart_and_reflen): Same.
	(get_depending_on_value_from_odo): Same.
	(get_data_offset): Same.
	(process_this_exception): Same.
	* lexio.cc (check_push_pop_directive): New function.
	(check_source_format_directive): Restrict regex search to 1 line.
	(cdftext::free_form_reference_format): Use new function.
	* parse.y: Define new CDF tokens, use new CDF state.
	* parse_ante.h (cdf_tokens): Use new CDF state.
	(redefined_token): Same.
	(class prog_descr_t): Remove obsolete CDF state.
	(class program_stack_t): Same.
	(current_call_convention): Same.
	* scan.l: Recognize new CDF tokens.
	* scan_post.h (is_cdf_token): Same.
	* symbols.h (cdf_current_tokens): Change current_call_convention to return void.
	* token_names.h: Regenerate.
	* udf/stored-char-length.cbl: Use new PUSH/POP CDF functionality.
	* util.cc (class cdf_directives_t): Define cdf_directives_t.
	(current_call_convention): Same.
	(cdf_current_tokens): Same.
	(cdf_dictionary): Same.
	(cdf_enabled_exceptions): Same.
	(cdf_push): Same.
	(cdf_push_call_convention): Same.
	(cdf_push_current_tokens): Same.
	(cdf_push_dictionary): Same.
	(cdf_push_enabled_exceptions): Same.
	(cdf_push_source_format): Same.
	(cdf_pop): Same.
	(cdf_pop_call_convention): Same.
	(cdf_pop_current_tokens): Same.
	(cdf_pop_dictionary): Same.
	(cdf_pop_enabled_exceptions): Same.
	(cdf_pop_source_format): Same.
	* util.h (cdf_push): Declare cdf_directives_t.
	(cdf_push_call_convention): Same.
	(cdf_push_current_tokens): Same.
	(cdf_push_dictionary): Same.
	(cdf_push_enabled_exceptions): Same.
	(cdf_push_source_format): Same.
	(cdf_pop): Same.
	(cdf_pop_call_convention): Same.
	(cdf_pop_current_tokens): Same.
	(cdf_pop_dictionary): Same.
	(cdf_pop_source_format): Same.
	(cdf_pop_enabled_exceptions): Same.

libgcobol/ChangeLog:

	* common-defs.h (cdf_enabled_exceptions): Use new CDF state.
2025-07-10 10:59:02 -04:00
GCC Administrator
285422c70e Daily bump. 2025-07-10 00:20:18 +00:00
Robert Dubner
069bf2fe31 cobol: Development round-up. [PR120765, PR119337, PR120794]
This collection of changes reflects development by both Jim Lowden and Bob
Dubner.  It includes fixes to the cobcd script; refinements to the multiple-
period syntax; changes to the parser; implementation of DISPLAY/ACCEPT to and
from ENVIRONMENT-NAME, ENVIRONMENT-VALUE, ARGUMENT-NUMBER, ARGUMENT-VALUE and
minor changes to genapi.cc to cut down on the number of cppcheck warnings.

Co-authored-by: James K. Lowden <jklowden@cobolworx.com>
Co-authored-by: Robert Dubner <rdubner@symas.com>

gcc/cobol/ChangeLog:

	PR cobol/120765
	PR cobol/119337
	PR cobol/120794
	* Make-lang.in: Take control of the .cc.o rule.
	* cbldiag.h (error_msg_direct): New declaration.
	(gcc_location_dump): Forward declaration.
	(location_dump): Use gcc_location_dump.
	* cdf.y: Change some tokens.
	* gcobc: Change dialect handling.
	* genapi.cc (parser_call_targets_dump): Temporarily remove from service.
	(parser_compile_dcls): Combine temporary arrays.
	(get_binary_value_from_float): Apply const to one parameter.
	(depending_on_value): Localize a boolean variable.
	(normal_normal_compare): Likewise.
	(cobol_compare): Eliminate cppcheck warning.
	(combined_name): Apply const to an input parameter.
	(parser_perform): Apply const to a variable.
	(parser_accept): Improve handling of special_name_t parameter and
	the exception conditions.
	(parser_display): Improve handling of speciat_name_t parameter; use the
	os_filename[] string when appropriate.
	(program_end_stuff): Rename shadowing variable.
	(parser_division): Consolidate temporary char[] arrays.
	(parser_file_start): Apply const to a parameter.
	(inspect_replacing): Likewise.
	(parser_program_hierarchy): Rename shadowing variable.
	(mh_identical): Apply const to parameters.
	(float_type_of): Likewise.
	(picky_memcpy): Likewise.
	(mh_numeric_display): Likewise.
	(mh_little_endian): Likewise.
	(mh_source_is_group): Apply static to a variable it.
	(move_helper): Quiet a cppcheck warning.
	* genapi.h (parser_accept): Add exceptions to declaration.
	(parser_accept_under_discussion): Add declaration.
	(parser_display): Change to std::vector; add exceptions to declaration.
	* lexio.cc (cdf_source_format): Improve source code location handling.
	(source_format_t::infer): Likewise.
	(is_fixed_format): Likewise.
	(is_reference_format): Likewise.
	(left_margin): Likewise.
	(right_margin): Likewise.
	(cobol_set_indicator_column): Likewise.
	(include_debug): Likewise.
	(continues_at): Likewise.
	(indicated): Likewise.
	(check_source_format_directive): Likewise.
	(cdftext::free_form_reference_format): Likewise.
	* parse.y: Tokens; program and function names; DISPLAY and ACCEPT
	handling.
	* parse_ante.h (class tokenset_t): Removed.
	(class current_tokens_t): Removed.
	(field_of): Removed.
	* scan.l: Token handling.
	* scan_ante.h (level_found): Comment.
	* scan_post.h (start_condition_str): Remove cast author_state:.
	* symbols.cc (symbols_update): Change error message.
	(symbol_table_init): Correct and reorder entries.
	(symbol_unresolved_file_key): New function definition.
	(cbl_file_key_t::deforward): Change error message.
	* symbols.h (symbol_unresolved_file_key): New declaration.
	(keyword_tok): New function.
	(redefined_token): New function.
	(class current_tokens_t): New class.
	* symfind.cc (symbol_match): Revise error message.
	* token_names.h: Reorder and change numbers in comments.
	* util.cc (class cdf_directives_t): New class.
	(cobol_set_indicator_column): New function.
	(cdf_source_format): New function.
	(gcc_location_set_impl): Improve column handling in token_location.
	(gcc_location_dump): New function.
	(class temp_loc_t): Modify constructor.
	(error_msg_direct): New function.
	* util.h (class source_format_t): New class.

libgcobol/ChangeLog:

	* libgcobol.cc (__gg__accept_envar): ACCEPT/DISPLAY environment variables.
	(accept_envar): Likewise.
	(default_exception_handler): Refine system log entries.
	(open_syslog): Likewise.
	(__gg__set_env_name): ACCEPT/DISPLAY environment variables.
	(__gg__get_env_name): ACCEPT/DISPLAY environment variables.
	(__gg__get_env_value): ACCEPT/DISPLAY environment variables.
	(__gg__set_env_value): ACCEPT/DISPLAY environment variables.
	(__gg__fprintf_stderr): Adjust __attribute__ for printf.
	(__gg__set_arg_num): ACCEPT/DISPLAY command-line arguments.
	(__gg__accept_arg_value): ACCEPT/DISPLAY command-line arguments.
	(__gg__get_file_descriptor): DISPLAY on os_filename[] /dev device.
2025-07-09 15:53:09 -04:00
GCC Administrator
c8124997a5 Daily bump. 2025-06-21 00:18:50 +00:00
James K. Lowden
632a50abc3 libgcobol: Add license.
libgcobol/ChangeLog:

	* LICENSE: New file.
2025-06-20 10:18:37 -04:00
GCC Administrator
a106ccb658 Daily bump. 2025-06-17 00:20:01 +00:00
James K. Lowden
f298fabf3f cobol: Some 1000 small changes in answer to cppcheck diagnostics.
constification per cppcheck. Use STRICT_WARN and fix reported
diagnostics.  Ignore [shadowVariable] in general. Use std::vector to
avoid exposing arrays as raw pointers.

	PR cobol/120621

gcc/cobol/ChangeLog:

	* Make-lang.in: Use STRICT_WARN.
	* cbldiag.h (location_dump): suppress shadowVariable.
	* cdf-copy.cc (esc): Fix shadowVariable.
	(copybook_elem_t::open_file): Do not use %m.
	* cdf.y: suppress invalidPrintfArgType for target format.
	* cdfval.h (struct cdfval_t): Suppress noExplicitConstructor.
	* cobol1.cc (cobol_name_mangler): Use C++ cast.
	* copybook.h (class copybook_elem_t): Same.
	* dts.h: Fixes and suppressions due to cppcheck.
	* except.cc (cbl_enabled_exceptions_t::status): Suppress useStlAlgorithm.
	(cbl_enabled_exceptions_t::turn_on_off): Const parameter.
	(class choose_declarative): Removed.
	* genapi.cc (struct called_tree_t): Explicit constructor.
	(parser_compile_ecs): Cast to void * for %p.
	(parser_compile_dcls): Same.
	(parser_statement_begin): Same.
	(initialize_variable_internal): Use std::vector for subscripts.
	(parser_initialize): Constification.
	(get_string_from): Same.
	(combined_name): Same.
	(parser_perform): Same.
	(psa_FldLiteralN): Same.
	(is_figconst): Const parameter.
	(is_figconst_t): Same.
	(parser_exit): Same.
	(parser_division): Const pointer.
	(parser_perform_conditional): Whitespace.
	(parser_set_conditional88): Const parameter.
	(inspect_tally): Use std::vector.
	(inspect_replacing): Same.
	(parser_inspect): Same.
	(parser_intrinsic_subst): Use std::vector (constuct elements).
	(parser_intrinsic_call_1): Use std::vector for subscripts.
	(is_ascending_key): Const pointer.
	(parser_sort): Use std::vector.
	(parser_file_sort): Same.
	(parser_file_merge): Same.
	(parser_unstring): Same.
	(parser_string): Same.
	(parser_call): Const pointer.
	(parser_program_hierarchy): Use std::vector.
	(conditional_abs): Const paraemeter.
	(float_type_of): Same.
	(initial_from_initial): Set value, quoted or not.
	(parser_symbol_add): Remove redundant nested test.
	* genapi.h (parser_add): Const parameters.
	(parser_subtract): Same.
	(parser_multiply): Same.
	(parser_divide): Same.
	(parser_perform): Same.
	(parser_exit): Same.
	(parser_initialize): Same.
	(parser_set_conditional88): Same.
	(parser_sort): Same.
	(parser_file_sort): Same.
	(parser_file_merge): Same.
	(parser_string): Same.
	(is_ascending_key): Same.
	* genmath.cc (arithmetic_operation): Use std::vector.
	(is_somebody_float): Const parameter.
	(all_results_binary): Const parameter.
	(fast_multiply): Remove redundant nested test.
	(parser_add): Const parameter.
	(parser_multiply): Remove redundant nested test.
	(parser_divide): Const parameter.
	(parser_subtract): Same.
	* genutil.cc (get_depending_on_value): Use std::vector.
	(get_data_offset): Same.
	(tree_type_from_field): Const parameter.
	(refer_has_depends): Const pointers.
	(get_literal_string): RAII.
	(refer_is_clean): Use std::vector.
	(get_time_nanoseconds): Newline at EOF.
	* genutil.h (tree_type_from_field): Remove declaration.
	* inspect.h (struct cbx_inspect_qual_t): Use std::vector.
	(struct cbl_inspect_qual_t): Same.
	(struct cbx_inspect_match_t): Same.
	(class cbl_inspect_match_t): Same.
	(struct cbx_inspect_replace_t): Same.
	(struct cbl_inspect_replace_t): Same.
	(struct cbx_inspect_oper_t): Same.
	(struct cbl_inspect_oper_t): Same.
	(struct cbx_inspect_t): Same.
	(struct cbl_inspect_t): Same.
	(parser_inspect): Same.
	* lexio.cc (indicated): Const pointer.
	(remove_inline_comment): Scope reduction.
	(maybe_add_space): Const pointer.
	(recognize_replacements): C++ cast.
	(check_source_format_directive): Same.
	(struct replacing_term_t): Explicit constructor.
	(parse_replace_pairs): Const reference.
	(location_in): Const reference.
	(parse_copy_directive): C++ cast.
	(parse_replace_last_off): Const parameter.
	(parse_replace_text): Const reference.
	(parse_replace_directive): C++ cast.
	(cdftext::lex_open): Const reference.
	(cdftext::open_output): Scope reduction.
	(cdftext::free_form_reference_format): Remove unused variable.
	(cdftext::process_file): Simplify.
	* lexio.h (struct bytespan_t): Use nullptr.
	(struct filespan_t): Initialize icol in constructor.
	(struct span_t): Suppress confused operatorEqRetRefThis.
	(struct replace_t): Eliminate single-value constructor.
	* parse.y: Many const cppcheck reports, and portable bit-shift.
	* parse_ante.h (reject_refmod): Const parameter.
	(require_pointer): Same.
	(require_integer): Same.
	(struct evaluate_elem_t): Explicit constructor.
	(struct arith_t): Use std::vector.
	(class eval_subject_t): Const parameter.
	(dump_inspect_match): Declare.
	(struct perform_t): Explicit constructor.
	(list_add):  Const parameter.
	(class tokenset_t): Avoid negative array index.
	(struct file_list_t): Explicit constructor.
	(struct field_list_t): Same.
	(struct refer_list_t): Same.
	(struct refer_marked_list_t): Const parameter.
	(struct refer_collection_t): Explicit constructor.
	(struct ast_inspect_oper_t): Remove class.
	(ast_inspect_oper_t): Same.
	(struct ast_inspect_t): Same.
	(struct ast_inspect_list_t): Same.
	(ast_inspect): Add location.
	(struct elem_list_t): Explicit constructor.
	(struct unstring_tgt_t): Same.
	(struct unstring_tgt_list_t): Same.
	(struct unstring_into_t): Same.
	(struct ffi_args_t): Same.
	(struct file_sort_io_t): Same.
	(merge_t): Same.
	(struct vargs_t): Same.
	(class prog_descr_t): Eliminate single-value constructor.
	(class program_stack_t): Suppress useStlAlgorithm.
	(struct rel_part_t): Eliminate single-value constructor.
	(class log_expr_t): Explicit constructor.
	(add_debugging_declarative): Rename local variable.
	(intrinsic_call_2): Const parameter.
	(invalid_key): Use std::find_if.
	(parser_add2): Const parameter.
	(parser_subtract2): Same.
	(stringify): Same.
	(unstringify): Same.
	(anybody_redefines): Same.
	(ast_call): Same.
	* parse_util.h (class cname_cmp): Explicit constructor.
	(intrinsic_inconsistent_parameter): Same.
	* scan_ante.h (struct cdf_status_t): Eliminate single-value constructor.
	(class enter_leave_t): Explicit constructor.
	(update_location): Const pointer, explicit constructor.
	(symbol_function_token): Const pointer.
	(typed_name): Same.
	* scan_post.h (datetime_format_of): Scope reduction.
	* show_parse.h (class ANALYZE): Use std::vector, explicit consstructor.
	* symbols.cc (symbol_table_extend): Scope reduction.
	(cbl_ffi_arg_t::cbl_ffi_arg_t): Define default constructor.
	(end_of_group): Const pointer.
	(symbol_find_odo): Const parameter.
	(rename_not_ok): Same.
	(field_str): Use %u instead of %d.
	(struct capacity_of): Const pointer.
	(symbols_update): Same.
	(symbol_field_parent_set): Same.
	(symbol_file_add): Same.
	(symbol_typedef_add): Same.
	(symbol_field_add): Use new operator=().
	(symbol_field): Suppress CastIntegerToAddressAtReturn.
	(symbol_register): Same.
	(symbol_file): Suppress knownConditionTrueFalse.
	(next_program): Const parameter.
	(symbol_file_record): Same.
	(class is_section): Explicit constructor.
	(cbl_file_t::no_key): Remove.
	(cbl_prog_hier_t::cbl_prog_hier_t): Use std::vector.
	(symbol_label_add): Assert pointer is not NULL.
	(symbol_label_section_exists): Const reference in lambda.
	(expand_picture): Use C++ cast.
	(symbol_program_callables): Const pointer.
	(symbol_currency_add): Suppress nullPointerRedundantCheck.
	(cbl_key_t): Use std::vector.
	(cbl_occurs_t::field_add): Const parameter.
	(cbl_occurs_t::index_add): Explicit constructor.
	(class is_field_at): Same.
	(cbl_file_key_t::deforward): Scope reduction.
	(cbl_file_t::keys_str): Use allocated memory only.
	(file_status_status_of): Const pointer.
	(is_register_field): Const parameter.
	* symbols.h (struct cbl_field_data_t): Eliminate single-value constructor.
	(struct cbl_occurs_bounds_t): Same.
	(struct cbl_refer_t): Use std::vector.
	(valid_move): Const parameter.
	(is_register_field): Same.
	(struct cbl_key_t): Use std::vector.
	(struct cbl_substitute_t): Eliminate single-value constructor.
	(refer_of): Return const reference
	(struct cbl_ffi_arg_t): Eliminate single-value constructor.
	(class temporaries_t): Same.
	(struct cbl_file_key_t): Define default constructor.
	(struct cbl_file_lock_t): Define copy constructor and operator=().
	(struct cbl_file_t): Complete default constructor.
	(struct symbol_elem_t): Explicit constructor.
	(symbol_elem_of): Suppress cstyleCast.
	(symbol_redefines): Const parameter.
	(struct cbl_field_t): Same.
	(cbl_section_of): Test for NULL pointer.
	(cbl_field_of): Same.
	(cbl_label_of): Same.
	(cbl_special_name_of): Same.
	(cbl_alphabet_of): Same.
	(cbl_file_of): Same.
	(is_figconst): Delete extra "struct" keyword.
	(is_figconst_low): Same.
	(is_figconst_zero): Same.
	(is_figconst_space): Same.
	(is_figconst_quote): Same.
	(is_figconst_high): Same.
	(is_space_value): Same.
	(is_quoted): Same.
	(symbol_index): Const parameter.
	(struct cbl_prog_hier_t): Suppress noExplicitConstructor.
	(struct cbl_perform_vary_t): Eliminate single-value constructor.
	(is_signable): Const parameter.
	(is_temporary): Same.
	(rename_not_ok): Same.
	(field_at): Test for NULL pointer.
	(class procref_base_t): Eliminate single-value constructor.
	* symfind.cc (is_data_field): Const pointer.
	(finalize_symbol_map2): Same.
	(class in_scope): Same.
	(symbol_match2): Same.
	* token_names.h: Suppress useInitializationList.
	* util.cc (normalize_picture): Whitespace and remove extra "continue".
	(redefine_field): Const pointer.
	(cbl_field_t::report_invalid_initial_value): Same.
	(literal_subscript_oob): Rename shadow variable.
	(cbl_refer_t::subscripts_set): Use std::vector.
	(cbl_refer_t::str): Same.
	(cbl_refer_t::deref_str): Same.
	(locally_unique): Use explicit constructor.
	(ambiguous_reference): Same.
	(class unique_stack): Use const reference.
	(cobol_filename): Const pointer.
	(verify_format): Scope reduction.
	(class temp_loc_t): Do not derive from YYLTYPE.
	(cobol_parse_files): Const pointer.
	* util.h (as_voidp): Define convenient converter.

libgcobol/ChangeLog:

	* common-defs.h (class cbl_enabled_exceptions_t): Const parameter.
2025-06-16 15:47:12 -04:00
GCC Administrator
d036322ada Daily bump. 2025-06-12 10:03:36 +00:00
Robert Dubner
582dda08ea cobol: Eliminate unguarded clock_gettime dependencies. [PR119975]
These changes are help make it possible to compile on MacOS.  In
addition to guarding clock_settime() calls, it removes the use
of structures and constants needed for clock_settime().

libgcobol/ChangeLog:

	PR cobol/119975
	* intrinsic.cc (__gg__current_date): Eliminate CLOCK_REALTIME.
	(__gg__seconds_past_midnight): Likewise.
	(__gg__formatted_current_date): Likewise.
	(__gg__random): Likewise.
	(__gg__random_next): Likewise.
	* libgcobol.cc: include <sys/time.h>.
	(__gg__abort): Eliminate CLOCK_REALTIME.
	(cobol_time): Likewise.
	(get_time_nanoseconds): Rename.
	(get_time_nanoseconds_local): Comment; Eliminate CLOCK_REALTIME.
	(__gg__clock_gettime): Likewise.
	(__gg__get_date_hhmmssff): Likewise.
	* libgcobol.h (__gg__clock_gettime): Eliminate clockid_t from declaration.
2025-06-11 16:07:58 -04:00
GCC Administrator
e1719c3c20 Daily bump. 2025-06-07 00:19:12 +00:00
Robert Dubner
37f5fdd008 cobol: Diagnostic messages, Flex build, and some cppcheck reports. [PR120328, PR119695]
Remove %0x and similar from diagnostic framework messages.  Remove %zu
from printf messages because it is not supported on some
platforms. Corrections in response to cppcheck.  Sundry small fixes.

gcc/cobol/ChangeLog:

	PR cobol/120328
	* Make-lang.in: Success with non-English locale.
	PR cobol/119695
	* cbldiag.h (cbl_unimplemented_at): Comment:
	* cdf-copy.cc (copybook_elem_t::open_file): Indentation.
	* cdf.y: YYABORT on certain errors.
	* cdfval.h (cdf_value): Const parameter.
	* copybook.h (class copybook_elem_t): Initialization.
	(class uppername_t): Explicit constructor.
	* except.cc (ec_type_descr): Remove %04s.
	(cbl_enabled_exceptions_t::dump): Remove %zu.
	* exceptg.h (class exception_turn_t): Explicit constructor.
	* genapi.cc (parser_perform_conditional): Remove %zu.
	(set_exception_environment): Formatting.
	(parser_statement_begin): Exception overhead.
	(parser_perform_conditional): Formatting:
	(parser_perform_conditional_end): Eliminate size_t.
	(parser_check_fatal_exception): Exception overhead.
	(parser_perform_conditional_end): Remove %zu.
	* inspect.h (struct cbx_inspect_match_t): Const reference.
	(struct cbx_inspect_t): Const parameter.
	* lexio.cc (cdftext::process_file): Remove %zu.
	* lexio.h (struct YYLTYPE): Remove unneeded struct.
	(YYLTYPE_IS_DECLARED): Likewise.
	(YYLTYPE_IS_TRIVIAL): Likewise.
	* parse.y: Comment; change DOT.
	* scan.l: Scan function names without swallowing whitespace.
	* scan_ante.h (scanner_parsing): Remove %zu.
	(scanner_parsing_pop): Remove %zu.
	(binary_integer_usage): Remove %zu.
	* scan_post.h (prelex): Correct post-CDF resumption.
	(yylex): Clearer message.
	* symbols.cc (symbol_table_extend): Explicit constructor.
	(elementize): Const parameter.
	(is_variable_length): Correct always-false.
	(symbols_update): Remove unnecessary shadow variable.
	(struct symbol_elem_t): Const parameter.
	(symbol_alphabet_add): Const parameter.
	(new_literal_add): Initialization.
	* symbols.h (class cbl_domain_elem_t): Correct assignment.
	(struct cbl_span_t): Improve constructor.
	(struct cbl_refer_t): Initialization.
	(struct cbl_alphabet_t): Rename shadow variable.
	(struct cbl_file_key_t): Remove unused constructor.
	(struct symbol_elem_t): Initialization.
	(struct cbl_until_addresses_t): Use unsigned int, for messages.
	(struct cbl_prog_hier_t): Initialization.
	(struct cbl_perform_tgt_t): Repair constructor.
	(struct cbl_label_t): Const parameter.
	(symbol_typedef_add): Const parameter.
	(symbol_field_add): Explicit constructor.
	(symbol_label_add): Explicit constructor.
	(symbol_program_add): Remove C-style "struct" use.
	(symbol_special_add): Remove C-style "struct" use.
	(symbol_alphabet_add): Const parameter.
	(symbol_file_add): Remove C-style "struct" use.
	(symbol_section_add): Remove C-style "struct" use.
	* symfind.cc: Const parameter.
	* util.cc (gb4): New function.
	* util.h (gb4): New function.
	* TODO: New file.

libgcobol/ChangeLog:

	* common-defs.h (enum cbl_file_mode_t): Whitespace.
	(enum file_stmt_t): Likewise.
	(ec_cmp): Likewise.
	(struct cbl_declarative_t): Add "explicit" keyword.
	(class cbl_enabled_exceptions_t): Whitespace.
	* gfileio.cc: Remove cppcheck comment.
	* libgcobol.cc (class ec_status_t): Add "explicit" keyword.
	(match_declarative): Remove %zu.
	(default_exception_handler): Likwise.
	(__gg__check_fatal_exception): Exception overhead.
	(__gg__exception_push): Remove %zu.
	(__gg__exception_pop): Likewise.
	(cbl_enabled_exception_t::dump): Likewise.
	(__gg__match_exception): Exception overhead; remove %zu.
	(cbl_enabled_exceptions_t::dump): Remove %zu.
	(__gg__set_exception_environment): Likewise.

Co-authored-by: James K. Lowden <jklowden@cobolworx.com>
Co-authored-by: Robert Dubner <rdubner@symas.com>
2025-06-06 16:43:30 -04:00
GCC Administrator
34701fe95d Daily bump. 2025-06-06 00:18:30 +00:00
Robert Dubner
2e334900f4 cobol: Guard clock_gettime(). [PR119975]
This attempts to eliminate "'clock_gettime' not declared..." when
building on x86_64-apple-darwin15.6.0.  Calls to clock_gettime have been
reduced to two locations.  Both have been guarded with

gcc/cobol/ChangeLog:

	PR cobol/119975
	* genapi.cc (parser_intrinsic_call_0): Use get_time_nanoseconds().
	* genutil.cc (get_time_64): Rename to get_time_nanoseconds().
	(get_time_nanoseconds): Likewise.
	* genutil.h (get_time_64): Likewise.
	(get_time_nanoseconds): Likewise.
	* util.cc (class cbl_timespec): Timing routine uses
	get_time_nanoseconds().
	(operator-): Likewise.
	(parse_file): Likewise.

libgcobol/ChangeLog:

	PR cobol/119975
	* configure.ac: AC_CHECK_LIB(rt, clock_gettime).
	* config.h.in: Likewise.
	* configure: Likewise.
	* gfileio.cc: Remove in-line cppcheck-suppress.
	* intrinsic.cc (timespec_to_string): Use guarded clock_gettime().
	(__gg__current_date): Likewise.
	(__gg__seconds_past_midnight): Likewise.
	(__gg__formatted_current_date): Likewise.
	(__gg__random): Likewise.
	(__gg__random_next): Likewise.
	(__gg__when_compiled): Likewise.
	* libgcobol.cc (cobol_time): Likewise.
	(get_time_nanoseconds): Likewise.
	(__gg__clock_gettime): Likewise.
	(__gg__get_date_hhmmssff): Likewise.
	* libgcobol.h (__gg__clock_gettime): Likewise.
	(struct cbl_timespec): Likewise.
2025-06-05 12:30:55 -04:00
GCC Administrator
cbeb02011d Daily bump. 2025-06-05 00:19:21 +00:00
Robert Dubner
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="&quot;%ld&quot;"/>
  <define name="GCC_PRISZ" value="&quot;z&quot;"/>
  <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.
2025-06-04 11:31:51 -04:00
GCC Administrator
fa715626d7 Daily bump. 2025-06-02 00:16:29 +00:00
Robert Dubner
213cb633e7 cobol: Wrap the call to fprintf in a libgcobol routine. [PR119524]
gcc/cobol/ChangeLog:

	PR cobol/119524
	* gengen.cc (gg_printf): Use the new __gg__fprintf_stderr() function
	instead of generating a call to fprintf().

libgcobol/ChangeLog:

	PR cobol/119524
	* libgcobol.cc (__gg__fprintf_stderr): New function.
2025-06-01 12:42:22 -04:00
GCC Administrator
fc12a4d6a8 Daily bump. 2025-05-21 00:17:57 +00:00
Robert Dubner
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>
2025-05-20 14:24:30 -04:00
Robert Dubner
d44beb1328 cobol: sqrt(0) is not an ec-argument error. [PR119885]
libgcobol

	PR cobol/119885
	* intrinsic.cc: (__gg__sqrt): Change test from <= zero to < zero.

gcc/testsuite

	* cobol.dg/group2/FUNCTION_SQRT__2_.cob: Testcase.
	* cobol.dg/group2/FUNCTION_SQRT__2_.out: Known-good for the testcase.
2025-05-20 11:56:01 -04:00
GCC Administrator
ca62131010 Daily bump. 2025-05-17 00:17:29 +00:00
Robert Dubner
92b6485a75 cobol: Eliminate exception "blob"; streamline some code generation.
This eliminates some of the last vestiges of creating a structure at host-time
that is intended for use at target-time.

It removes some unnecessary processing when exceptions are not enabled.

It improves the creation of code that handles table subscripts and refmod
parameters.

gcc/cobol/ChangeLog:

	* cobol1.cc (cobol_langhook_handle_option): Eliminate OPT_M.
	* except.cc (cbl_enabled_exception_t::dump): Formatting.
	(symbol_declaratives_add): Remove.
	(declarative_runtime_match): Change to no-blob processing.
	* exceptg.h (declarative_runtime_match): Change declaration.
	(symbol_declaratives_add): Remove declaration.
	* gcobc: Dialect handling.
	* genapi.cc (parser_compile_ecs): Formatting; add SHOW_IF_PARSE.
	(parser_compile_dcls): Likewise.
	(parser_statement_begin): Avoid unnecessary store_location_stuff() call.
	(gg_get_depending_on_value): Streamline get_depending_on_value_from_odo().
	(depending_on_value): Likewise.
	(parser_display_field): Formatting.
	(parser_display): Handle case ENV_NAME_e.
	(parser_file_open): Avoid unnecessary store_location_stuff.
	(parser_file_close): Likewise.
	(parser_file_read): Likewise.
	(parser_file_write): Likewise.
	(parser_file_delete): Likewise.
	(parser_file_rewrite): Likewise.
	(parser_file_start): Likewise.
	(parser_intrinsic_subst): Streamline get_depending_on_value_from_odo().
	(parser_intrinsic_call_1): Likewise.
	(parser_lsearch_start): Likewise.
	(parser_bsearch_start): Likewise.
	(parser_sort): Likewise.
	(store_location_stuff): Avoid unnecessary assignments.
	(parser_pop_exception): Formatting.
	* genmath.cc (parser_add): Avoid var_decl_default_compute_error assignment
	when doing fast_add().
	(parser_subtract): Likewise.
	* genutil.cc (REFER): Macro for analyzing code generation.
	(get_integer_value): Use data_decl_node for integer value from FldLiteralN.
	(get_data_offset): Streamline exception code processing.
	(get_and_check_refstart_and_reflen): Likewise.
	(get_depending_on_value_from_odo): Likewise.
	(get_depending_on_value): Likewise.
	(refer_is_clean): Formatting.
	(refer_refmod_length): Streamline exception code processing.
	(refer_fill_depends): Likewise.
	(refer_offset): Likewise.
	(refer_size_dest): Likewise.
	(refer_size_source): Likewise.
	* genutil.h (get_depending_on_value_from_odo): Likewise.
	* lang-specs.h: Options definition.
	* lang.opt: -M as in c.opt.
	* lexio.h: Formatting.
	* parse.y: Expand -dialect suggestions; SECTION SEGMENT messages.
	* parse_ante.h (declarative_runtime_match): Dialect handling.
	(labels_dump): Likewise.
	(class current_tokens_t): Likewise.
	(class prog_descr_t): Make program_index size_t to prevent padding bytes.
	* scan.l: POP_FILE directive.
	* scan_ante.h (class enter_leave_t): Better handle line number when
	processing COPY statements.
	* symbols.cc (symbol_elem_cmp): Eliminate SymFunction.
	(symbols_dump): Likewise.
	(symbol_label_section_exists): Likewise.
	* symbols.h (NAME_MAX): Eliminate.  (Was part of SymFunction).
	(dialect_is): Improve dialect handling.
	(dialect_gcc): Likewise.
	(dialect_ibm): Likewise.
	(dialect_gnu): Likewise.
	(enum symbol_type_t): Eliminate SymFunction.
	* util.cc (symbol_type_str): Likewise.
	(class unique_stack): Option -M handling.
	(cobol_set_pp_option): Likewise.
	(parse_file): Likewise.
	* util.h (cobol_set_pp_option): Likewise.

libgcobol/ChangeLog:

	* common-defs.h (struct cbl_declarative_t): Eliminate blobl.
	* libgcobol.cc (__gg__set_env_name): Code for ENVIRONMENT-NAME/VALUE.
	(__gg__set_env_value): Likewise.

gcc/testsuite/ChangeLog:

	* cobol.dg/group1/declarative_1.cob: Handle modified exception handling.
2025-05-16 12:10:09 -04:00
GCC Administrator
92430eec52 Daily bump. 2025-05-14 00:18:21 +00:00
Rainer Orth
90fee97d52 libgcobol: Allow for lack of LOG_PERROR
The libgcobol build is broken again on Solaris:

/vol/gcc/src/hg/master/local/libgcobol/libgcobol.cc: In function ‘void
default_exception_handler(ec_type_t)’:
/vol/gcc/src/hg/master/local/libgcobol/libgcobol.cc:11196:44: error:
‘LOG_PERROR’ was not declared in this scope; did you mean ‘LOG_ERR’?
11196 | static int priority = LOG_INFO, option = LOG_PERROR, facility =
LOG_USER;
      |                                            ^~~~~~~~~~
      |                                            LOG_ERR
/vol/gcc/src/hg/master/local/libgcobol/libgcobol.cc:11202:28: error:
‘facility’ was not declared in this scope
11202 |     openlog(ident, option, facility);
      |                            ^~~~~~~~

LOG_PERROR is a BSD extension not present on Solaris due to its System V
heritage, and Linux syslog(3) documents:

       LOG_PERROR     (Not in POSIX.1-2001 or  POSIX.1-2008.)   Also  log  the
                      message to stderr.

This patch provides a fallback definition, just the minimum to unbreak
the build.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2025-05-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libgcobol:
	* libgcobol.cc [!LOG_PERROR] (LOG_PERROR): Provide fallback.
2025-05-13 09:43:48 +02:00
GCC Administrator
c90439b84b Daily bump. 2025-05-12 00:16:36 +00:00
Robert Dubner
d7d24f9cc5 cobol: Eliminate padding bytes from cbl_declarative_t. [PR119377]
By changing the type of a variable in the cbl_declarative_t structure from "bool"
to "uint32_t", three uninitialized padding bytes were turned into initialized
bytes.  This eliminates the valgrind error caused by those uninitialized values.

This is an interim fix, which expediently eliminates the valgrind problem. The
underlying design flaw, which involves turning a host-side C++ structure into
a run-time data block, is slated for complete replacement in the next few weeks.

libgcobol/ChangeLog:

	PR cobol/119377
	* common-defs.h: (struct cbl_declaratives_t): Change "bool global" to
	"uint32_t global".
2025-05-11 13:54:58 -04:00
GCC Administrator
fed88d5459 Daily bump. 2025-05-11 00:16:50 +00:00
Robert Dubner
a3f5aac402 cobol: Auto-detect source format; some FldLiteralN; infer gcobc name. [PR119337]
This commit includes changes to the parser's auto-detection heuristic for source
code formatting.  The heuristic now examines the line containing "program-id" to
determine whether the code is in ISO "fixed-form reference format", or ISO
"free-form reference format", or the IBM "extended source format".

Changes to the parser also changes to token processing.

On the code generation side, there are some changes that begin to process
numeric literals in order generate more efficient code using information known
at compilation time.

gcc/cobol/ChangeLog:

	PR cobol/119337

	* Make-lang.in: Change how $(FLEX) is invoked.
	* cdf.y: Change parser tokens.
	* gcobc: Changed how name is inferred for PR119337
	* gcobol.1: Documentation for SOURCE format heuristic
	* genapi.cc: Eliminate __gg__odo_violation.
	(parser_display_field): Change comment.
	* genutil.cc:Eliminate __gg__odo_violation.
	(REFER): New macro for analyzing subscript/refmod calculations.
	(get_integer_value): Likewise.
	(get_data_offset): Eliminate __gg__odo_violation.
	(scale_by_power_of_ten_N): Eliminate unnecessary var_decl_rdigits operation.
	(refer_is_clean): Check for FldLiteralN.
	(REFER_CHECK): Eliminate.
	(refer_refmod_length): Streamline var_decl_rdigits processing.
	(refer_fill_depends): Likewise.
	(refer_offset): Streamline processing when FldLiteralN.
	(refer_size): Tag with REFER macro.
	(refer_size_dest): Likewise.
	(refer_size_source): Likewise.
	* genutil.h (get_integer_value): Delete declaration for odo_violation;
	change comment for get_integer_value
	(REFER_CHECK): Delete declaration.
	(refer_check): Delete #define.
	* lexio.cc (is_fixed_format): Changes for source format auto-detect.
	(is_reference_format): Likewise.
	(check_source_format_directive): Likewise.
	(valid_sequence_area): Likewise.
	(is_p): Likewise.
	(is_program_id): Likewise.
	(likely_nist_file): Likewise.
	(infer_reference_format): Likewise.
	(cdftext::free_form_reference_format): Likewise.
	* parse.y: Token changes.
	* parse_ante.h (class tokenset_t):  Likewise.
	(class current_tokens_t):  Likewise.
	(cmd_or_env_special_of): Likewise.
	* scan.l:  Likewise.
	* scan_ante.h (bcomputable): Likewise.
	(keyword_alias_add): Likewise.
	(struct bint_t): Likewise.
	(binary_integer_usage): Likewise.
	(binary_integer_usage_of): Likewise.
	* scan_post.h (start_condition_str): Likewise.
	* symbols.cc (symbol_table_init): Formatting.
	* symbols.h (struct cbl_field_data_t): Add "input" method to field_data_t.
	(keyword_alias_add): Add forward declaration.
	(binary_integer_usage_of): Likewise.
	* token_names.h: Change list of tokens.
	* util.cc (iso_cobol_word): Change list of COBOL reserved words.

libgcobol/ChangeLog:

	* common-defs.h (ec_cmp): Delete "getenv("match_declarative")" calls.
	(enabled_exception_match): Delete "getenv("match_declarative")" calls.
	* libgcobol.cc: Eliminate __gg__odo_violation.

gcc/testsuite/ChangeLog:

	* cobol.dg/group1/simple-if.cob: Make explicitly >>SOURCE FREE
2025-05-10 18:49:13 -04:00
GCC Administrator
9175741f0d Daily bump. 2025-05-09 00:18:17 +00:00
Rainer Orth
fdd2374b87 libgcobol: Heed --enable-libgcobol
If some target isn't listed as supported in configure.tgt,
--enable-libgcobol cannot override that.  However, that's what should
happen just like an explicit --enable-languages=cobol forces the
frontend to be built.

This patch, shamelessly adapted from libphobos, does just that.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2025-04-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libgcobol:
	* configure.ac: Handle --enable-libgcobol.
	Let it override LIBGCOBOL_SUPPORTED.
	* configure: Regenerate.
2025-05-08 09:42:42 +02:00
GCC Administrator
d4da4474dd Daily bump. 2025-05-07 00:18:28 +00:00