[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-07-31 Thread simonsobisch at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

Simon Sobisch  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|REOPENED|RESOLVED

--- Comment #10 from Simon Sobisch  ---
rechecked, working now

note: the last commits did remove the use of the variables "out_set" and
"first", so their initial setup may be dropped as well

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-07-29 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

--- Comment #9 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Robert Dubner
:

https://gcc.gnu.org/g:4a3e130f39e5b4dbeea0f7a116afa4545453b213

commit r15-10146-g4a3e130f39e5b4dbeea0f7a116afa4545453b213
Author: Robert Dubner 
Date:   Wed Jul 9 12:24:38 2025 -0400

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 
Co-authored-by: Robert Dubner 

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_enva

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-07-29 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

--- Comment #8 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Robert Dubner
:

https://gcc.gnu.org/g:704bf38f08e24479258729b54db074895707a290

commit r15-10120-g704bf38f08e24479258729b54db074895707a290
Author: Robert Dubner 
Date:   Sat May 10 18:05:29 2025 -0400

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

(cherry picked from commit a3f5aac402a7ef721e1e832f96ed77ec21f5a25c)

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-07-09 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

--- Comment #7 from GCC Commits  ---
The master branch has been updated by Robert Dubner :

https://gcc.gnu.org/g:069bf2fe31e99f0415ddb6acaf76cfb6eee8bb6a

commit r16-2155-g069bf2fe31e99f0415ddb6acaf76cfb6eee8bb6a
Author: Robert Dubner 
Date:   Wed Jul 9 12:24:38 2025 -0400

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 
Co-authored-by: Robert Dubner 

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

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-07-01 Thread jklowden at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

--- Comment #6 from James K. Lowden  ---
Pending patch answers default output filename and default dialect: 

$ gcobcx=0  /usr/local/gcc-cobol/bin/gcobc -g failures/jkl/tbug2.cbl 
+ exec /usr/local/gcc-cobol/bin/gcobol -shared -dialect mf -dialect gnu -g
-fPIC -o tbug2.so failures/jkl/tbug2.cbl -fno-static-call

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-06-23 Thread jklowden at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

James K. Lowden  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jklowden at gcc dot 
gnu.org

--- Comment #5 from James K. Lowden  ---
Local patch pending. 

diff --git a/gcc/cobol/gcobc b/gcc/cobol/gcobc
index 8c2245f5f82..01c75dd191e 100755
--- a/gcc/cobol/gcobc
+++ b/gcc/cobol/gcobc
@@ -35,6 +35,10 @@
 ##output set the mode variable.  Everything else is appended to the
 ##opts variable.
 ##
+##  - -fPIC is added to the command line if $mode is "-shared".  That
+##option applies only to "certain machines", per the gcc info
+##manual. For this script to be portable across machines, -fPIC
+##would have to be set more judiciously.

 if [ "$COBCPY" ]
 then
@@ -478,12 +482,13 @@ do

 *) if [ -z "$output_name" ]  # first non-option argument is source
file name
then
-   output_name=$(basename ${opt%.*})
+   output_name=$(basename "${opt%.*}")
case $mode in
-c) output_name="$output_name".o
;;
-shared)
output_name="$output_name".so
+   opts="$opts -fPIC"
;;
esac
opts="$opts -o $output_name"

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-06-23 Thread simonsobisch at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

Simon Sobisch  changed:

   What|Removed |Added

 Resolution|FIXED   |---
 Status|RESOLVED|REOPENED

--- Comment #4 from Simon Sobisch  ---
While it works for the more simple cases, it broke gcobc's documented
"everything not handled explicit is passed to gcobol" behaviour.

For exampple calling with "gcobc -g" or "gcobc -dialect gnu" now raises

basename: invalid option -- 'g'
basename: invalid option -- 'd'

applied local fix:

```diff
-*) if [ -z "$output_name" ]  # first non-option argument is source
file +*) if [ -z "$output_name" ] && [ -f "${opt%.*}" ]  # first
non-option argument is source file name
name
then
-   output_name=$(basename ${opt%.*})
+   output_name=$(basename "${opt%.*}")
```

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-05-20 Thread rdubner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

Robert Dubner  changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |FIXED
 CC||rdubner at gcc dot gnu.org

--- Comment #3 from Robert Dubner  ---
I am closing this on Jim Lowden's behalf.

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-05-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

--- Comment #2 from GCC Commits  ---
The master branch has been updated by Robert Dubner :

https://gcc.gnu.org/g:a3f5aac402a7ef721e1e832f96ed77ec21f5a25c

commit r16-520-ga3f5aac402a7ef721e1e832f96ed77ec21f5a25c
Author: Robert Dubner 
Date:   Sat May 10 18:05:29 2025 -0400

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

[Bug cobol/119337] cobol: gcobc wrapper should deduce output name

2025-05-09 Thread jklowden at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119337

James K. Lowden  changed:

   What|Removed |Added

 CC||jklowden at gcc dot gnu.org
 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2025-05-09
 Ever confirmed|0   |1

--- Comment #1 from James K. Lowden  ---
This is fixed in parser branch.  It should be automatically marked as fixed by
gitlab when it is applied to master+cobol branch.