aboutsummaryrefslogtreecommitdiff
path: root/gcc/cobol/gcobc
AgeCommit message (Collapse)AuthorFilesLines
2025-07-09cobol: Development round-up. [PR120765, PR119337, PR120794]Robert Dubner1-17/+24
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-06-30cobol: Revise diagnostic linemap management.James K. Lowden1-1/+6
Update linemap filename before location in both parsers. Rely on parser to update linemap. Lexer maintains location. Various small syntax corrections and extensions. PR cobol/120772 PR cobol/120779 PR cobol/120790 PR cobol/120791 PR cobol/120794 gcc/cobol/ChangeLog: * gcobc: Supply -fPIC for shared objects. * genapi.cc (linemap_add): Delete empty macro. (parser_enter_file): Do not call linemap_add. (parser_leave_file): Same. * gengen.cc (location_from_lineno): Remove function. * lexio.cc (parse_replacing_term): Allow empty term. (cdftext::process_file): Always append to output. (cdftext::segment_line): Output #line directives. * lexio.h (struct span_t): Count lines in span. * parse.y: Revamp REPOSITORY, and minor syntax extensions. * parse_ante.h (input_file_status_notify): Update linemap filename before location. (intrinsic_token_of): Declare. (parser_move_carefully): Support MOVE pointer. * parse_util.h (intrinsic_token_of): New function. * scan.l: New EOF logic, accept NOT=, own yylloc and yylineno. * scan_ante.h (class enter_leave_t): Do not store newline count. (cdf_location_set): Remove declaration. (ydfltype_of): New function. (update_location): Accept location parameter. (reset_location): New function. (YY_USER_ACTION): Use update_location(). (YY_USER_INIT): Update CDF location. (verify_ws): New function. (wait_for_the_child): Removed. * symbols.h (cobol_fileline_set): return line number. * util.cc (valid_move): Use range-based for loop. (struct input_file_t): Remove line_map pointer. (class unique_stack): New peek() member function. (cobol_lineno_save): Rename to overload cobol_lineno(). (cobol_lineno): Replaces cobol_lineno_save(). (cobol_filename): Return void. (location_from_lineno): New function used by genapi.cc. (cdf_location_set): Remove. (matched_length): No change. (cobol_fileline_set): Return line number. (fisspace): Remove extra semicolon. (fisprint): Same. * util.h (cobol_filename_restore): Return void. (cobol_lineno_save): Remove declaration. (cobol_lineno): Declare.
2025-05-20cobol: Multiple PRs; formatting; exception processing.Robert Dubner1-56/+85
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-16cobol: Eliminate exception "blob"; streamline some code generation.Robert Dubner1-1/+1
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-10cobol: Auto-detect source format; some FldLiteralN; infer gcobc name. [PR119337]Robert Dubner1-2/+29
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-03-11COBOL: FrontendJames K. Lowden1-0/+465
gcc/cobol/ * LICENSE: New file. * Make-lang.in: New file. * config-lang.in: New file. * lang.opt: New file. * lang.opt.urls: New file. * cbldiag.h: New file. * cdfval.h: New file. * cobol-system.h: New file. * copybook.h: New file. * dts.h: New file. * exceptg.h: New file. * gengen.h: New file. * genmath.h: New file. * genutil.h: New file. * inspect.h: New file. * lang-specs.h: New file. * lexio.h: New file. * parse_ante.h: New file. * parse_util.h: New file. * scan_ante.h: New file. * scan_post.h: New file. * show_parse.h: New file. * structs.h: New file. * symbols.h: New file. * token_names.h: New file. * util.h: New file. * cdf-copy.cc: New file. * lexio.cc: New file. * scan.l: New file. * parse.y: New file. * genapi.cc: New file. * genapi.h: New file. * gengen.cc: New file. * genmath.cc: New file. * genutil.cc: New file. * cdf.y: New file. * cobol1.cc: New file. * convert.cc: New file. * except.cc: New file. * gcobolspec.cc: New file. * structs.cc: New file. * symbols.cc: New file. * symfind.cc: New file. * util.cc: New file. * gcobc: New file. * gcobol.1: New file. * gcobol.3: New file. * help.gen: New file. * udf/stored-char-length.cbl: New file.