Subject: [PATCH] cobol: Eliminate cppcheck warnings in gcc/cobol .cc
files.

These changes eliminate various cppcheck warnings, mostly involving
C-Style
casting and applying "const" to various variables and formal parameters.
Some tab characters were eliminated, and some lines were trimmed to
seventy-nine characters.

gcc/cobol/ChangeLog:

        * cobol1.cc (cobol_langhook_handle_option): Eliminate cppcheck
warnings.
        * dts.h: Likewise.
        * except.cc (cbl_enabled_exceptions_t::dump): Likewise.
        * gcobolspec.cc (lang_specific_driver): Likewise.
        * genapi.cc (parser_file_merge): Likewise.
        * gengen.cc (gg_unique_in_function): Likewise.
        (gg_declare_variable): Likewise.
        (gg_peek_fn_decl): Likewise.
        (gg_define_function): Likewise.
        * genmath.cc (set_up_on_exception_label): Likewise.
        (set_up_compute_error_label): Likewise.
        (arithmetic_operation): Likewise.
        (fast_divide): Likewise.
        * genutil.cc (get_and_check_refstart_and_reflen): Likewise.
        (get_depending_on_value_from_odo): Likewise.
        (get_data_offset): Likewise.
        (get_binary_value): Likewise.
        (process_this_exception): Likewise.
        (copy_little_endian_into_place): Likewise.
        (refer_is_clean): Likewise.
        (refer_fill_depends): Likewise.
        * genutil.h (process_this_exception): Likewise.
        (copy_little_endian_into_place): Likewise.
        (refer_is_clean): Likewise.
        * lexio.cc (check_push_pop_directive): Likewise.
        (check_source_format_directive): Likewise.
        (location_in): Likewise.
        (lexer_input): Likewise.
        (cdftext::lex_open): Likewise.
        (lexio_dialect_mf): Likewise.
        (valid_sequence_area): Likewise.
        (cdftext::free_form_reference_format): Likewise.
        (cdftext::segment_line): Likewise.
        * lexio.h (struct span_t): Likewise.
        * scan_ante.h (trim_location): Likewise.
        * symbols.cc (symbol_elem_cmp): Likewise.
        (symbol_alphabet): Likewise.
        (end_of_group): Likewise.
        (cbl_field_t::attr_str): Likewise.
        (symbols_update): Likewise.
        (symbol_typedef_add): Likewise.
        (symbol_field_add): Likewise.
        (new_temporary_impl): Likewise.
        (symbol_label_section_exists): Likewise.
        (symbol_program_callables): Likewise.
        (file_status_status_of): Likewise.
        * symfind.cc (is_data_field): Likewise.
        (finalize_symbol_map2): Likewise.
        (class in_scope): Likewise.
        (symbol_match2): Likewise.
        * util.cc (get_current_dir_name): Likewise.
        (gb4): Likewise.
        (class cdf_directives_t): Likewise.
        (cbl_field_t::report_invalid_initial_value): Likewise.
        (literal_subscript_oob): Likewise.
        (cbl_refer_t::str): Likewise.
        (date_time_fmt): Likewise.
        (class unique_stack): Likewise.
        (cobol_set_pp_option): Likewise.
        (cobol_filename): Likewise.
        (cobol_filename_restore): Likewise.
        (gcc_location_set_impl): Likewise.
        (ydferror): Likewise.
        (error_msg_direct): Likewise.
        (yyerror): Likewise.
        (cbl_unimplemented_at): Likewise.
---
 gcc/cobol/cobol1.cc     |  8 +++--
 gcc/cobol/dts.h         |  2 +-
 gcc/cobol/except.cc     |  2 +-
 gcc/cobol/gcobolspec.cc |  5 +--
 gcc/cobol/genapi.cc     |  3 +-
 gcc/cobol/gengen.cc     | 15 ++++----
 gcc/cobol/genmath.cc    | 25 +++++++------
 gcc/cobol/genutil.cc    | 80 +++++++++++++++++++++++------------------
 gcc/cobol/genutil.h     |  6 ++--
 gcc/cobol/lexio.cc      | 31 ++++++++--------
 gcc/cobol/lexio.h       |  4 +--
 gcc/cobol/scan_ante.h   |  3 +-
 gcc/cobol/symbols.cc    | 50 +++++++++++++++-----------
 gcc/cobol/symfind.cc    | 14 ++++----
 gcc/cobol/util.cc       | 79 +++++++++++++++++++++-------------------
 15 files changed, 177 insertions(+), 150 deletions(-)

diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc
index 4bd79f1f605..3146da57899 100644
--- a/gcc/cobol/cobol1.cc
+++ b/gcc/cobol/cobol1.cc
@@ -357,7 +357,7 @@ cobol_langhook_handle_option (size_t scode,
             return true;
 
         case OPT_M:
-           cobol_set_pp_option('M');
+            cobol_set_pp_option('M');
             return true;
 
         case OPT_fstatic_call:
@@ -368,16 +368,18 @@ cobol_langhook_handle_option (size_t scode,
             wsclear(cobol_default_byte);
             return true;
 
-        case OPT_fflex_debug:
+        case OPT_fflex_debug: // cppcheck-suppress syntaxError // The
need for this is a mystery
             yy_flex_debug = 1;
             cobol_set_debugging( true, yy_debug == 1, cobol_trace_debug
== 1 );
             return true;
+
         case OPT_fyacc_debug:
             yy_debug = 1;
             cobol_set_debugging(yy_flex_debug == 1,
                                 true,
                                 cobol_trace_debug == 1 );
             return true;
+
         case OPT_ftrace_debug:
             cobol_set_debugging( yy_flex_debug == 1, yy_debug == 1, true
);
             return true;
@@ -406,11 +408,13 @@ cobol_langhook_handle_option (size_t scode,
         case OPT_fsyntax_only:
           mode_syntax_only(identification_div_e);
           break;
+
         case OPT_preprocess:
           if( ! preprocess_filter_add(arg) ) {
             cbl_errx( "could not execute preprocessor %s", arg);
           }
           return true;
+
         case OPT_include:
           if( ! include_file_add(arg) ) {
             cbl_errx( "could not include %s", arg);
diff --git a/gcc/cobol/dts.h b/gcc/cobol/dts.h
index e12b979e6a1..c900c4515a7 100644
--- a/gcc/cobol/dts.h
+++ b/gcc/cobol/dts.h
@@ -110,6 +110,6 @@ namespace dts {
                     } );
     return true;
   }
-};
+}
 
 
diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc
index e42aea2924b..df1c7dfb1d1 100644
--- a/gcc/cobol/except.cc
+++ b/gcc/cobol/except.cc
@@ -96,7 +96,7 @@ cbl_enabled_exceptions_t::dump() const {
     return;
   }
   int i = 1;
-  for( auto& elem : *this ) {
+  for( auto& elem : *this ) { // cppcheck-suppress constVariableReference
     dbgmsg("cbl_enabled_exceptions_t: %2d  {%s, %s, %lu}",
            i++,
            elem.location? "with location" : "  no location", 
diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc
index 70784d7e357..9532d4256b2 100644
--- a/gcc/cobol/gcobolspec.cc
+++ b/gcc/cobol/gcobolspec.cc
@@ -529,7 +529,8 @@ lang_specific_driver (struct cl_decoded_option
**in_decoded_options,
   // cl_decoded_option
 
   size_t new_option_count = new_opt.size();
-  struct cl_decoded_option *new_options = XNEWVEC (struct
cl_decoded_option, new_option_count);
+  struct cl_decoded_option *new_options = XNEWVEC (struct
cl_decoded_option,
+                                                    new_option_count);
 
   for(size_t i=0; i<new_option_count; i++)
     {
@@ -539,7 +540,7 @@ lang_specific_driver (struct cl_decoded_option
**in_decoded_options,
 #ifdef NOISY
   verbose = true;
 #endif
-  if( verbose && new_options != original_options )
+  if( verbose && new_options != original_options ) // cppcheck-suppress
knownConditionTrueFalse
     {
     fprintf(stderr, _("Driving: (" HOST_SIZE_T_PRINT_DEC ")\n"),
             (fmt_size_t)new_option_count);
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 23a66221d0b..a293912fc6b 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -12315,7 +12315,8 @@ parser_file_merge(  cbl_file_t *workfile,
   ELSE
     ENDIF
 
-  cbl_enabled_exceptions_t& enabled_exceptions( cdf_enabled_exceptions()
);
+  const cbl_enabled_exceptions_t&
+                                enabled_exceptions(
cdf_enabled_exceptions() );
   
   for(size_t i=0; i<ninputs; i++)
     {
diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc
index 2b688d64628..7395350e28a 100644
--- a/gcc/cobol/gengen.cc
+++ b/gcc/cobol/gengen.cc
@@ -140,7 +140,7 @@ struct cbl_translation_unit_t gg_trans_unit;
 // the compiler when a source code module makes that mistake.
 static std::unordered_set<std::string> names_we_have_seen;
 
-// This vector is used to process the function_decls at the point we
leave 
+// This vector is used to process the function_decls at the point we
leave
 // the file.
 static std::vector<tree> finalized_function_decls;
 
@@ -893,7 +893,7 @@ gg_create_assembler_name(const char *cobol_name)
 static char *
 gg_unique_in_function(const char *var_name, gg_variable_scope_t vs_scope)
   {
-  char *retval = (char *)xmalloc(strlen(var_name)+32);
+  char *retval = static_cast<char *>(xmalloc(strlen(var_name)+32));
   if( (vs_scope == vs_stack || vs_scope == vs_static) )
     {
     sprintf(retval, "%s." HOST_SIZE_T_PRINT_DEC, var_name,
@@ -1028,10 +1028,7 @@ gg_declare_variable(tree type_decl,
       break;
     }
   DECL_INITIAL(var_decl) = initial_value;
-  if( unique_name )
-    {
-    free(unique_name);
-    }
+  free(unique_name);
   return var_decl;
   }
 
@@ -2521,12 +2518,12 @@ gg_peek_fn_decl(const char *funcname, tree
fndecl_type)
     }
   return retval;
   }
-  
+
 tree
 gg_build_fn_decl(const char *funcname, tree fndecl_type)
   {
   tree function_decl;
-  
+
   std::string key = function_decl_key(funcname, fndecl_type);
   std::unordered_map<std::string, tree>::const_iterator it =
           map_of_function_decls.find(key);
@@ -2617,13 +2614,13 @@ gg_define_function( tree return_type,
     }
   va_end(params);
 
+  char ach[32];
   std::unordered_set<std::string>::const_iterator it =
           names_we_have_seen.find(funcname);
   if( it != names_we_have_seen.end() )
     {
     static int bum_counter = 1;
     // We have seen this name before.  Replace it with something unique:
-    char ach[32];
     sprintf(ach, "..no_dupes.%d", bum_counter++);
     funcname = ach;
     }
diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc
index 0a1c12dd61e..e74aebd059e 100644
--- a/gcc/cobol/genmath.cc
+++ b/gcc/cobol/genmath.cc
@@ -52,7 +52,8 @@ set_up_on_exception_label(cbl_label_t *arithmetic_label)
     if( !arithmetic_label->structs.arith_error )
       {
       arithmetic_label->structs.arith_error
-        = (cbl_arith_error_t *)xmalloc(sizeof(struct cbl_arith_error_t)
);
+        = static_cast<cbl_arith_error_t *>
+                                  (xmalloc(sizeof(struct
cbl_arith_error_t)));
       // Set up the address pairs for this clause
 
gg_create_goto_pair(&arithmetic_label->structs.arith_error->over.go_to,
 
&arithmetic_label->structs.arith_error->over.label);
@@ -72,8 +73,8 @@ set_up_compute_error_label(cbl_label_t *compute_label)
     if( !compute_label->structs.compute_error )
       {
       compute_label->structs.compute_error
-        = (cbl_compute_error_t *)
-          xmalloc(sizeof(struct cbl_compute_error_t) );
+        = static_cast<cbl_compute_error_t *>
+          (xmalloc(sizeof(struct cbl_compute_error_t)));
       compute_label->structs.compute_error->compute_error_code
         = gg_define_int(0);
       }
@@ -112,7 +113,6 @@ arithmetic_operation(size_t nC, cbl_num_result_t *C,
     {
     TRACE1_HEADER
     TRACE1_TEXT_ABC("calling ", operation, "")
-    TRACE1_END
     for(size_t ii=0; ii<nA; ii++)
       {
       TRACE1_INDENT
@@ -129,7 +129,6 @@ arithmetic_operation(size_t nC, cbl_num_result_t *C,
                   build_int_cst_type(SIZE_T, ii));
       TRACE1_REFER("", B[ii], "");
       }
-    TRACE1_END
     }
 
   // We need to split up cbl_num_result_t into two arrays, one for the
refer_t
@@ -223,7 +222,6 @@ arithmetic_operation(size_t nC, cbl_num_result_t *C,
     {
     for(size_t ii=0; ii<nC; ii++)
       {
-      break;  // Breaks on ADD 1 SUB2 GIVING SUB4 both PIC S9(3) COMP
       TRACE1_INDENT
       gg_fprintf( trace_handle,
                   1, "result: C[%ld]: ",
@@ -663,8 +661,10 @@ fast_divide(size_t nC, cbl_num_result_t *C,
       // We now either divide into C[n] or assign dividend/divisor to
C[n]:
       for(size_t i=0; i<nC; i++ )
         {
-        tree dest_type =
tree_type_from_size(C[i].refer.field->data.capacity, 0);
-        tree dest_addr = gg_add(member(C[i].refer.field->var_decl_node,
"data"),
+        tree dest_type =
+
tree_type_from_size(C[i].refer.field->data.capacity, 0);
+        tree dest_addr = gg_add(member( C[i].refer.field->var_decl_node,
+                                        "data"),
                                 refer_offset(C[i].refer));
         tree ptr = gg_cast(build_pointer_type(dest_type), dest_addr);
         if( nB )
@@ -680,16 +680,15 @@ fast_divide(size_t nC, cbl_num_result_t *C,
           }
 
         // This is where we handle any remainder, keeping in mind that
for
-        // nB != 0, the actual dividend is in the value we have named
"divisor".
-        //
-        // And, yes, I hate comments like that, too.
+        // nB != 0, the actual dividend is in the value we have named
+        // "divisor".
 
         // We calculate the remainder by calculating
         //    dividend minus quotient * divisor
         if( remainder.field )
           {
-          tree dest_addr = gg_add(member(remainder.field->var_decl_node,
"data"),
-                                  refer_offset(remainder));
+          dest_addr = gg_add( member(remainder.field->var_decl_node,
"data"),
+                              refer_offset(remainder));
           dest_type = tree_type_from_size(remainder.field->data.capacity,
0);
           ptr = gg_cast(build_pointer_type(dest_type), dest_addr);
 
diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc
index e09b1bfb8e0..20b47aba9b9 100644
--- a/gcc/cobol/genutil.cc
+++ b/gcc/cobol/genutil.cc
@@ -307,7 +307,8 @@ get_and_check_refstart_and_reflen(  tree
refstart,// LONG returned value
                                     tree         reflen,  // LONG
returned value
                                     cbl_refer_t &refer)
   {
-  cbl_enabled_exceptions_t& enabled_exceptions( cdf_enabled_exceptions()
);
+  const cbl_enabled_exceptions_t&
+                                enabled_exceptions(
cdf_enabled_exceptions() );
 
   if( !enabled_exceptions.match(ec_bound_ref_mod_e) )
     {
@@ -460,7 +461,8 @@ get_depending_on_value_from_odo(tree retval,
cbl_field_t *odo)
       declarative with a RESUME NEXT STATEMENT, or before the
default_condition
       processing can do a controlled exit.
       */
-  cbl_enabled_exceptions_t& enabled_exceptions( cdf_enabled_exceptions()
);
+  const cbl_enabled_exceptions_t&
+                                enabled_exceptions(
cdf_enabled_exceptions() );
   cbl_field_t *depending_on;
   depending_on = cbl_field_of(symbol_at(odo->occurs.depending_on));
 
@@ -474,8 +476,8 @@ get_depending_on_value_from_odo(tree retval,
cbl_field_t *odo)
     return;
     }
 
-  // Bounds checking is enabled, so we test the DEPENDING ON value to be
between
-  // the lower and upper OCCURS limits:
+  // Bounds checking is enabled, so we test the DEPENDING ON value to be
+  // between the lower and upper OCCURS limits:
   get_integer_value(retval,
                     depending_on,
                     NULL,
@@ -485,23 +487,28 @@ get_depending_on_value_from_odo(tree retval,
cbl_field_t *odo)
     {
     // This needs to evaluate to an integer
     set_exception_code(ec_bound_odo_e);
-    gg_assign(retval, build_int_cst_type(TREE_TYPE(retval),
odo->occurs.bounds.lower));
+    gg_assign(retval, build_int_cst_type( TREE_TYPE(retval),
+                                          odo->occurs.bounds.lower));
     gg_assign(var_decl_rdigits, integer_zero_node);
     }
   ELSE
     ENDIF
 
-  IF( retval, gt_op, build_int_cst_type(TREE_TYPE(retval),
odo->occurs.bounds.upper) )
+  IF( retval, gt_op, build_int_cst_type(TREE_TYPE(retval),
+                                        odo->occurs.bounds.upper) )
     {
     set_exception_code(ec_bound_odo_e);
-    gg_assign(retval, build_int_cst_type(TREE_TYPE(retval),
odo->occurs.bounds.lower));
+    gg_assign(retval, build_int_cst_type( TREE_TYPE(retval),
+                                          odo->occurs.bounds.lower));
     }
   ELSE
     {
-    IF( retval, lt_op, build_int_cst_type(TREE_TYPE(retval),
odo->occurs.bounds.lower) )
+    IF( retval, lt_op, build_int_cst_type(TREE_TYPE(retval),
+                                          odo->occurs.bounds.lower) )
       {
       set_exception_code(ec_bound_odo_e);
-      gg_assign(retval, build_int_cst_type(TREE_TYPE(retval),
odo->occurs.bounds.lower));
+      gg_assign(retval, build_int_cst_type( TREE_TYPE(retval),
+                                            odo->occurs.bounds.lower));
       }
     ELSE
       ENDIF
@@ -551,7 +558,6 @@ get_data_offset(cbl_refer_t &refer,
   // We have a refer.
   // At the very least, we have an constant offset
   int all_flags = 0;
-  int all_flag_bit = 1;
 
   if( refer.nsubscript() )
     {
@@ -571,6 +577,7 @@ get_data_offset(cbl_refer_t &refer,
     // Establish the field_t pointer for walking up through our
ancestors:
     cbl_field_t *parent = refer.field;
 
+    int all_flag_bit = 1;
     // Note the backwards test, because refer->nsubscript is an unsigned
value
     for(size_t i=refer.nsubscript()-1; i<refer.nsubscript(); i-- )
       {
@@ -604,7 +611,8 @@ get_data_offset(cbl_refer_t &refer,
         }
       else
         {
-          cbl_enabled_exceptions_t& enabled_exceptions(
cdf_enabled_exceptions() );
+        const cbl_enabled_exceptions_t&
+                                enabled_exceptions(
cdf_enabled_exceptions() );
         if( !enabled_exceptions.match(ec_bound_subscript_e) )
           {
           // With no exception testing, just pick up the value
@@ -629,21 +637,25 @@ get_data_offset(cbl_refer_t &refer,
             }
           ELSE
             {
-            IF( subscript, lt_op, gg_cast(TREE_TYPE(subscript),
integer_one_node) )
+            IF( subscript, lt_op, gg_cast(TREE_TYPE(subscript),
+                                          integer_one_node) )
               {
               // The subscript is too small
               set_exception_code(ec_bound_subscript_e);
-              gg_assign(subscript,
build_int_cst_type(TREE_TYPE(subscript), 1));
+              gg_assign(subscript,
build_int_cst_type(TREE_TYPE(subscript),
+                                                      1));
               }
             ELSE
               {
               IF( subscript,
                   ge_op,
-                  build_int_cst_type(TREE_TYPE(subscript),
parent->occurs.ntimes()) )
+                  build_int_cst_type( TREE_TYPE(subscript),
+                                      parent->occurs.ntimes()) )
                 {
                 // The subscript is too large
                 set_exception_code(ec_bound_subscript_e);
-                gg_assign(subscript,
build_int_cst_type(TREE_TYPE(subscript), 1));
+                gg_assign(subscript,
build_int_cst_type(TREE_TYPE(subscript),
+                                                        1));
                 }
               ELSE
                 {
@@ -658,16 +670,19 @@ get_data_offset(cbl_refer_t &refer,
 
       all_flag_bit <<= 1;
 
-      // Although we strictly don't need to look at the ODO value at this
point,
-      // we do want it checked for the purposes of ec-bound-odo
+      // Although we strictly don't need to look at the ODO value at this
+      // point, we do want it checked for the purposes of ec-bound-odo
 
-      cbl_enabled_exceptions_t& enabled_exceptions(
cdf_enabled_exceptions() );
+      const cbl_enabled_exceptions_t&
+                                enabled_exceptions(
cdf_enabled_exceptions() );
 
       if( enabled_exceptions.match(ec_bound_odo_e) )
         {
         if( parent->occurs.depending_on )
           {
-          static tree value64 = gg_define_variable(LONG,
".._gdos_value64", vs_file_static);
+          static tree value64 = gg_define_variable( LONG,
+                                                    ".._gdos_value64",
+                                                    vs_file_static);
           cbl_field_t *odo = symbol_find_odo(parent);
           get_depending_on_value_from_odo(value64, odo);
           }
@@ -1244,20 +1259,15 @@ get_binary_value( tree value,
       break;
       }
 
-    case FldAlphanumeric:
-      {
-
-      }
-
-
     default:
       {
-      fprintf(stderr, "%s(): We know not how to"
-                      " get a binary value from %s\n",
-                      __func__,
-                      cbl_field_type_str(field->type) );
+      char *err = xasprintf("%s(): We know not how to"
+                            " get a binary value from %s\n",
+                            __func__,
+                            cbl_field_type_str(field->type) );
+      cbl_internal_error("%s", err);
       abort();
-      break;
+      // break; // break not needed after abort();
       }
     }
 
@@ -1673,9 +1683,9 @@ set_exception_code_func(ec_type_t ec, int /*line*/,
int from_raise_statement)
   }
 
 bool
-process_this_exception(ec_type_t ec)
+process_this_exception(const ec_type_t ec)
   {
-  cbl_enabled_exceptions_t& enabled_exceptions( cdf_enabled_exceptions()
);
+  const cbl_enabled_exceptions_t& enabled_exceptions(
cdf_enabled_exceptions() );
   bool retval;
   if( enabled_exceptions.match(ec) || !skip_exception_processing )
     {
@@ -1707,7 +1717,7 @@ copy_little_endian_into_place(cbl_field_t *dest,
                               tree value,
                               int rhs_rdigits,
                               bool check_for_error,
-                              tree &size_error)
+                        const tree &size_error)
   {
   if( check_for_error )
     {
@@ -1933,7 +1943,7 @@ get_literal_string(cbl_field_t *field)
   }
 
 bool
-refer_is_clean(cbl_refer_t &refer)
+refer_is_clean(const cbl_refer_t &refer)
   {
   if( !refer.field || refer.field->type == FldLiteralN )
     {
@@ -1980,7 +1990,7 @@ refer_refmod_length(cbl_refer_t &refer)
 
 static
 tree // size_t
-refer_fill_depends(cbl_refer_t &refer)
+refer_fill_depends(const cbl_refer_t &refer)
   {
   REFER("");
   // This returns a positive number which is the amount a depends-limited
diff --git a/gcc/cobol/genutil.h b/gcc/cobol/genutil.h
index 0d9028e035c..20783e1f8f7 100644
--- a/gcc/cobol/genutil.h
+++ b/gcc/cobol/genutil.h
@@ -118,7 +118,7 @@ void      set_exception_code_func(ec_type_t ec,
                                   int line,
                                   int from_raise_statement=0);
 #define set_exception_code(ec) set_exception_code_func(ec, __LINE__)
-bool      process_this_exception(ec_type_t ec);
+bool      process_this_exception(const ec_type_t ec);
 #define   CHECK_FOR_FRACTIONAL_DIGITS true
 void      get_integer_value(tree value,  // This is always a LONG
                             cbl_field_t *field,
@@ -130,7 +130,7 @@ void      copy_little_endian_into_place(cbl_field_t
*dest,
                                         tree value,
                                         int rhs_rdigits,
                                         bool check_for_error,
-                                        tree &size_error);
+                                  const tree &size_error);
 tree      build_array_of_size_t( size_t  N,
                                  const size_t *values);
 void      parser_display_internal_field(tree file_descriptor,
@@ -138,7 +138,7 @@ void      parser_display_internal_field(tree
file_descriptor,
                                         bool advance=DISPLAY_NO_ADVANCE);
 char     *get_literal_string(cbl_field_t *field);
 
-bool      refer_is_clean(cbl_refer_t &refer);
+bool      refer_is_clean(const cbl_refer_t &refer);
 
 tree      refer_offset(cbl_refer_t &refer,
                        int *pflags=NULL);
diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc
index dc632c2ecd8..52d1affee81 100644
--- a/gcc/cobol/lexio.cc
+++ b/gcc/cobol/lexio.cc
@@ -344,7 +344,7 @@ check_push_pop_directive( filespan_t& mfile ) {
   std::swap(*mfile.eol, eol); // see implementation for excuses
   bool ok = regex_search(p, const_cast<const char *>(mfile.eol), cm, re);
   std::swap(*mfile.eol, eol);
-  
+
   if( ok ) {
     gcc_assert(cm.size() > 1);
     bool push = TOUPPER(cm[1].first[1]) == 'U';
@@ -400,7 +400,7 @@ check_source_format_directive( filespan_t& mfile ) {
   std::swap(*mfile.eol, eol); // see implementation for excuses
   bool ok = regex_search(p, const_cast<const char *>(mfile.eol), cm, re);
   std::swap(*mfile.eol, eol);
-  
+
   if( ok ) {
     gcc_assert(cm.size() > 1);
     switch( cm[3].length() ) {
@@ -417,7 +417,7 @@ check_source_format_directive( filespan_t& mfile ) {
 
     dbgmsg( "%s:%d: %s format set, on line " HOST_SIZE_T_PRINT_UNSIGNED,
             __func__, __LINE__,
-            cdf_source_format().description(), 
+            cdf_source_format().description(),
             (fmt_size_t)mfile.lineno() );
     char *bol = cdf_source_format().is_fixed()? mfile.cur :
const_cast<char*>(cm[0].first);
     gcc_assert(cm[0].second <= mfile.eol);
@@ -941,7 +941,7 @@ location_in( const filespan_t& mfile, const
csub_match& cm ) {
   gcc_assert(mfile.cur <= cm.first && cm.second <= mfile.eodata);
   auto nline = std::count(cm.first, cm.second, '\n');
   if( nline ) {
-    gcc_assert(loc.first_line < nline);
+    gcc_assert(nline < loc.first_line);
     loc.first_line -= nline;
     auto p = static_cast<const char*>(memrchr(cm.first, '\n',
cm.length()));
     loc.last_column = (cm.second) - p;
@@ -1379,13 +1379,13 @@ lexer_input( char buf[], int max_size, FILE *input
) {
   for( auto p = mfile.cur; p < next; *output.pos++ = *p++ ) {
     static bool at_bol = false;
     if( at_bol ) {
-      auto nonblank = std::find_if( p, next,
+      auto nonblank_l = std::find_if( p, next,
                                     []( char ch ) {
                                       return !isblank(ch); } );
-      if( nonblank + 1 < next ) {
-        if( *nonblank == '\r' ) nonblank++; // Windows
-        if( *nonblank == '\n' ) {
-          p = nonblank;
+      if( nonblank_l + 1 < next ) {
+        if( *nonblank_l == '\r' ) nonblank_l++; // Windows
+        if( *nonblank_l == '\n' ) {
+          p = nonblank_l;
           continue;
         }
       }
@@ -1513,7 +1513,6 @@ cdftext::lex_open( const char filename[] ) {
 
   // Process any files supplied by the -include command-line option.
   for( auto name : included_files ) {
-    int input;
     if( -1 == (input = open(name, O_RDONLY)) ) {
       yyerrorvl(1, "", "cannot open -include file %s", name);
       continue;
@@ -1686,7 +1685,7 @@ bool lexio_dialect_mf();
  */
 static const char *
 valid_sequence_area( const char *data, const char *eodata ) {
-  
+
   for( const char *p = data;
        (p = std::find_if(p, eodata, is_p)) != eodata;
        p++ )
@@ -1709,7 +1708,7 @@ valid_sequence_area( const char *data, const char
*eodata ) {
       }
     }
   }
-  return nullptr;  
+  return nullptr;
 }
 
 /*
@@ -1745,7 +1744,7 @@ cdftext::free_form_reference_format( int input ) {
   } current( mfile.data );
 
   /*
-   * Infer source code format. 
+   * Infer source code format.
    */
   if( cdf_source_format().inference_pending()  ) {
     const char *bol = valid_sequence_area(mfile.data, mfile.eodata);
@@ -1983,15 +1982,15 @@ cdftext::segment_line( filespan_t& mfile ) {
     struct { unsigned long ante, post; } lineno = {
       gb4(mfile.lineno()), gb4(mfile.lineno() + segment.after.nlines())
     };
-    char *directive = lineno.ante == lineno.post?
+    const char *directive = lineno.ante == lineno.post?
       nullptr : xasprintf("\n#line %lu \"%s\"\n",
                           lineno.ante, cobol_filename());
 
-    if( directive ) 
+    if( directive )
       output.push_back( span_t(strlen(directive), directive) );
     output.push_back( span_t(mfile.cur, segment.before.p) );
     output.push_back( span_t(segment.after.p, segment.after.pend ) );
-    if( directive ) 
+    if( directive )
       output.push_back( span_t(strlen(directive), directive) );
 
     mfile.cur = const_cast<char*>(segment.before.pend);
diff --git a/gcc/cobol/lexio.h b/gcc/cobol/lexio.h
index eb41068d50e..ba4ef0adb8e 100644
--- a/gcc/cobol/lexio.h
+++ b/gcc/cobol/lexio.h
@@ -244,8 +244,8 @@ struct span_t {
     return span_t(output, eout);
   }
   const char * has_nul() const {
-    auto p = std::find(this->p, pend, '\0');
-    return p != pend? p : NULL;
+    auto p_l = std::find(this->p, pend, '\0');
+    return p_l != pend? p_l : NULL;
   }
 
   bool at_eol() const {
diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h
index 88a8e8c3609..6128a3f2fce 100644
--- a/gcc/cobol/scan_ante.h
+++ b/gcc/cobol/scan_ante.h
@@ -490,7 +490,8 @@ trim_location( int nkeep) {
          (fmt_size_t)nline, (fmt_size_t)rescan.size());
   if( nline ) {
     gcc_assert( yylloc.first_line + nline <= yylloc.last_line );
-    yylloc.last_line =- int(nline);
+    yylloc.last_line -= int(nline);
+    gcc_assert( yylloc.first_line <= yylloc.last_line );
     char *p = static_cast<char*>(memrchr(rescan.p, '\n', rescan.size()));
     yylloc.last_column = rescan.pend - ++p;
     return;
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index 4b347298a24..aaaa6f335d1 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -500,13 +500,13 @@ symbol_elem_cmp( const void *K, const void *E )
       }
       return strcasecmp(key.name, elem.name);
     }
-    break;
+    // break; // This break not needed if all options do a return.
   case SymSpecial:
     return special_pair_cmp(k->elem.special, e->elem.special)? 0 : 1;
-    break;
+    // break; // This break not needed after return.
   case SymAlphabet:
     return strcasecmp(k->elem.alphabet.name, e->elem.alphabet.name);
-    break;
+    // break; // This break not needed after return.
   case SymFile:
     // If the key is global, so must be the found element.
     if( (cbl_file_of(k)->attr & global_e) == global_e &&
@@ -514,7 +514,7 @@ symbol_elem_cmp( const void *K, const void *E )
       return 1;
     }
     return strcasecmp(k->elem.file.name, e->elem.file.name);
-    break;
+    // break; // This break not needed after return.
   }
   assert(k->type == SymField);
 
@@ -672,7 +672,7 @@ symbol_special( size_t program, const char name[] )
 struct symbol_elem_t *
 symbol_alphabet( size_t program, const char name[] )
 {
-  cbl_alphabet_t alphabet(YYLTYPE(), custom_encoding_e);
+  cbl_alphabet_t alphabet(YYLTYPE(), custom_encoding_e); //
cppcheck-suppress syntaxError
   assert(strlen(name) < sizeof alphabet.name);
   strcpy(alphabet.name, name);
 
@@ -931,7 +931,7 @@ end_of_group( size_t igroup ) {
       if( e->program != group->program ) return isym;
       if( e->type == SymLabel ) return isym; // end of data division
       if( e->type == SymField ) {
-        const auto f = cbl_field_of(e);
+        const cbl_field_t * f = cbl_field_of(e);
         if( f->level == LEVEL77 || f->level == 66 ) return isym;
         if( f->level == 1 && f->parent != igroup ) {
           return isym;
@@ -1174,7 +1174,7 @@ static struct symbol_elem_t *
         // If an 01 record exists for the FD/SD, use its capacity as the
         // default_record capacity.
         if( p != symbols_end() ) {
-          const auto record = cbl_field_of(p);
+          const cbl_field_t * record = cbl_field_of(p);
           assert(record->level == 1);
           e = calculate_capacity(p);
           auto record_size = std::max(record->data.memsize,
@@ -1262,7 +1262,7 @@ static struct symbol_elem_t *
 
     // If group has a parent that is a record area, expand it, too.
     if( 0 < group->parent ) {
-      auto redefined = symbol_redefines(group);
+      redefined = symbol_redefines(group);
       if( redefined && is_record_area(redefined) ) {
         if( redefined->data.capacity < group->data.memsize ) {
           redefined->data.capacity = group->data.memsize;
@@ -1434,11 +1434,11 @@ cbl_field_t::attr_str( const
std::vector<cbl_field_attr_t>& attrs ) const
   const char *sep = "";
   char *out = NULL;
 
-  for( auto attr : attrs ) {
+  for( auto attr_l : attrs ) {
     char *part = out;
-    if( has_attr(attr) ) {
+    if( has_attr(attr_l) ) {
       int erc = asprintf(&out, "%s%s%s",
-                         part? part : "", sep, cbl_field_attr_str(attr));
+                         part? part : "", sep,
cbl_field_attr_str(attr_l));
       if( -1 == erc ) return part;
       free(part);
       sep = ", ";
@@ -1745,7 +1745,7 @@ symbols_update( size_t first, bool parsed_ok ) {
 
     bool size_invalid = field->data.memsize > 0 &&
symbol_redefines(field);
     if( size_invalid ) { // redefine of record area is ok
-      const auto redefined = symbol_redefines(field);
+      const cbl_field_t * redefined = symbol_redefines(field);
       size_invalid = ! is_record_area(redefined);
     }
     if( !field->is_valid() || size_invalid )
@@ -1828,7 +1828,7 @@ symbols_update( size_t first, bool parsed_ok ) {
     }
 
     // Verify REDEFINing field has no ODO components
-    const auto parent = symbol_redefines(field);
+    const cbl_field_t * parent = symbol_redefines(field);
     if( parent && !is_record_area(parent) && is_variable_length(field) )
{
       ERROR_FIELD(field, "line %d: REDEFINES field %s cannot be variable
length",
                field->line, field->name);
@@ -2470,7 +2470,7 @@ symbol_typedef_add( size_t program, struct
cbl_field_t *field ) {
   auto e = symbols_end() - 1;
   assert( symbols_begin() < e );
   if( e->type == SymField ) {
-    const auto f = cbl_field_of(e);
+    const cbl_field_t * f = cbl_field_of(e);
     if( f == field ) return e;
   }
 
@@ -2520,7 +2520,8 @@ symbol_field_add( size_t program, struct cbl_field_t
*field )
     if( is_numeric(parent->usage) && parent->data.capacity > 0 ) {
       field->type = parent->usage;
       field->data = parent->data;
-      field->data = 0;
+      field->data = 0;  // cppcheck-suppress redundantAssignment
+      //                // cppcheck doesn't understand multiple
overloaded operator=
       field->data.initial = NULL;
     }
   }
@@ -3144,7 +3145,6 @@ static cbl_field_t *
 new_temporary_impl( enum cbl_field_type_t type, const cbl_name_t name =
nullptr )
 {
   extern int yylineno;
-  static int nstack, nliteral;
   static const struct cbl_field_t empty_alpha = {
                                 0, FldAlphanumeric, FldInvalid,
                                 intermediate_e, 0, 0, 0, nonarray, 0, "",
@@ -3213,8 +3213,10 @@ new_temporary_impl( enum cbl_field_type_t type,
const cbl_name_t name = nullptr
 
   f->line = yylineno;
   if( is_literal(type) ) {
+    static int nliteral = 0;
     snprintf(f->name, sizeof(f->name), "_literal%d",++nliteral);
   } else {
+    static int nstack = 0;
     snprintf(f->name, sizeof(f->name), "_stack%d",++nstack);
   }
 
@@ -3728,6 +3730,12 @@ symbol_label_add( size_t program, cbl_label_t
*input )
 bool
 symbol_label_section_exists( size_t eval_label_index ) {
   auto eval = symbols_begin(eval_label_index);
+  /*  cppcheck warns that the following statement depends on the order of
+      evaluation of side effects.  Since this isn't my code, and since I
don't
+      think the warning can be eliminated without rewriting it, I am just
+      supprressing it.
+      -- Bob Dubner, 2025-07-14 */
+  // cppcheck-suppress unknownEvaluationOrder
   bool has_section = std::any_of( ++eval, symbols_end(),
                                [program = eval->program]( const auto& sym
) {
                                  if( program == sym.program && sym.type
== SymLabel ) {
@@ -4187,7 +4195,7 @@ symbol_program_callables( size_t program ) {
     if( e->type != SymLabel ) continue;
     if( e->elem.label.type != LblProgram ) continue;
 
-    const auto prog = cbl_label_of(e);
+    const cbl_label_t * prog = cbl_label_of(e);
     if( program == symbol_index(e) && !prog->recursive ) continue;
 
     if( (self->parent == prog->parent && prog->common) ||
@@ -4658,9 +4666,11 @@ file_status_status_of( file_status_t status ) {
   size_t n = COUNT_OF(file_status_fields);
   const file_status_field_t *fs, key { status };
 
-  fs = (file_status_field_t*)lfind( &key, file_status_fields,
-                                    &n, sizeof(*fs), cbl_file_status_cmp
);
-
+  fs = static_cast<file_status_field_t*>(lfind( &key,
+                                                file_status_fields,
+                                                &n,
+                                                sizeof(*fs),
+                                                cbl_file_status_cmp ));
   return fs? (long)fs->status : -1;
 }
 
diff --git a/gcc/cobol/symfind.cc b/gcc/cobol/symfind.cc
index c04bb0fbcdc..8141b2206e6 100644
--- a/gcc/cobol/symfind.cc
+++ b/gcc/cobol/symfind.cc
@@ -48,7 +48,7 @@ extern int yydebug;
 static bool
 is_data_field( symbol_elem_t& e ) {
   if( e.type != SymField ) return false;
-  const auto f = cbl_field_of(&e);
+  const cbl_field_t *f = cbl_field_of(&e);
   if( f->name[0] == '\0' ) return false;
   if( is_filler(f) ) return false;
 
@@ -129,7 +129,7 @@ finalize_symbol_map2() {
   for( auto& elem : symbol_map2 ) {
     auto& fields( elem.second );
     fields.remove_if( []( auto isym ) {
-                       const auto f = cbl_field_of(symbol_at(isym));
+                       const cbl_field_t *f =
cbl_field_of(symbol_at(isym));
                        return f->type == FldInvalid;
                      } );
     if( fields.empty() ) empties.insert(elem.first);
@@ -316,9 +316,9 @@ public:
       if( p != item.second.end() ) {
         // Preserve symbol's index at front of ancestor list.
         symbol_map_t::mapped_type shorter(1 + ancestors->size());
-        auto p = shorter.begin();
-        *p = item.second.front();
-        shorter.insert( ++p, ancestors->begin(), ancestors->end() );
+        auto p_l = shorter.begin();
+        *p_l = item.second.front();
+        shorter.insert( ++p_l, ancestors->begin(), ancestors->end() );
         return make_pair(item.first, shorter);
       }
     }
@@ -341,7 +341,7 @@ class in_scope {
   size_t program;
 
   static size_t prog_of( size_t program ) {
-    const auto L = cbl_label_of(symbol_at(program));
+    const cbl_label_t *L = cbl_label_of(symbol_at(program));
     return L->parent;
   }
 
@@ -430,7 +430,7 @@ symbol_match2( size_t program,
   auto plist = symbol_map2.find(key);
   if( plist != symbol_map2.end() ) {
     for( auto candidate : plist->second ) {
-      const auto e = symbol_at(candidate);
+      const symbol_elem_t *e = symbol_at(candidate);
       if( name_has_names( e, names, local ) ) {
         fields.push_back( symbol_index(e) );
       }
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index afa159787fb..6439f23abc7 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -93,7 +93,7 @@ static inline char *
 get_current_dir_name ()
 {
   /* Use libiberty's allocator here.  */
-  char *buf = (char *) xmalloc (PATH_MAX);
+  char *buf = static_cast<char *>(xmalloc (PATH_MAX));
   return getcwd (buf, PATH_MAX);
 }
 #endif
@@ -101,7 +101,7 @@ get_current_dir_name ()
 /*
  * For printing messages, usually the size of the thing is some kind of
string
  * length, and doesn't really need a size_t.  For message formatting, use
a
- * simple unsigned long, and warn if that's no good.  "gb4" here stands
for 
+ * simple unsigned long, and warn if that's no good.  "gb4" here stands
for
  * "4 Gigabytes".
  */
 unsigned long
@@ -113,7 +113,7 @@ gb4( size_t input ) {
   }
   return input;
 }
-  
+
 /*
  * Most CDF Directives -- those that have state -- can be pushed and
popped.
  * This class maintains stacks of them, with each stack having a "default
@@ -140,20 +140,20 @@ gb4( size_t input ) {
  *   PAGE
  *   PROPAGATE
  *   REF-MOD-ZERO-LENGTH
- * 
- * >>PUSH ALL calls the class's push() method. 
- * >>POP ALL calls the class's pop() method. 
+ *
+ * >>PUSH ALL calls the class's push() method.
+ * >>POP ALL calls the class's pop() method.
  */
 class cdf_directives_t
 {
   template <typename T>
-  class cdf_stack_t : private std::stack<T> {
+  class cdf_stack_t : private std::stack<T> { // cppcheck-suppress
noConstructor
     T default_value;
     const T& top() const { return std::stack<T>::top(); }
     bool empty() const { return std::stack<T>::empty(); }
    public:
     void value( const T& value ) {
-      T& output( empty()? default_value : std::stack<T>::top() );
+      T& output( empty()? default_value : std::stack<T>::top() ); //
cppcheck-suppress constVariableReference
       output = value;
       dbgmsg("cdf_directives_t::%s: %s", __func__, str(output).c_str());
     }
@@ -166,7 +166,7 @@ class cdf_directives_t
     }
     void pop() {
       if( empty() ) {
-        error_msg(YYLTYPE(), "CDF stack empty");
+        error_msg(YYLTYPE(), "CDF stack empty"); // cppcheck-suppress
syntaxError
         return;
       }
       default_value = top();
@@ -190,7 +190,6 @@ class cdf_directives_t
     static std::string str(cbl_enabled_exceptions_t) {
       return "<enabled_exceptions>";
     }
-                          
   };
 
  public:
@@ -203,7 +202,7 @@ class cdf_directives_t
   cdf_directives_t() {
     call_convention.value() = cbl_call_cobol_e;
   }
- 
+
   void push() {
     call_convention.push();
     cobol_words.push();
@@ -995,7 +994,7 @@ cbl_field_t::report_invalid_initial_value(const
YYLTYPE& loc) const {
         // 8 or more, we need do no further testing because we assume
         // everything fits.
         if( data.capacity < 8 ) {
-          const auto p = strchr(data.initial, symbol_decimal_point());
+          const char *p = strchr(data.initial, symbol_decimal_point());
           if( p && atoll(p+1) != 0 ) {
             error_msg(loc, "integer type %s VALUE '%s' "
                      "requires integer VALUE",
@@ -1141,7 +1140,7 @@ literal_subscript_oob( const cbl_refer_t& r, size_t&
isub /* output */)  {
                            pdim++;
                            return ! occurs.subscript_ok(r.field);
                          } );
-  isub = psub - r.subscripts.begin(); 
+  isub = psub - r.subscripts.begin();
   return psub == r.subscripts.end()? NULL : dims[isub];
 }
 
@@ -1154,12 +1153,12 @@ cbl_refer_t::subscripts_set( const
std::list<cbl_refer_t>& subs ) {
 
 const char *
 cbl_refer_t::str() const {
-  static char subscripts[64];
-  sprintf(subscripts, "(%u of " HOST_SIZE_T_PRINT_UNSIGNED "
dimensions)",
+  static char subscripts_l[64];
+  sprintf(subscripts_l, "(%u of " HOST_SIZE_T_PRINT_UNSIGNED "
dimensions)",
           nsubscript(), (fmt_size_t)dimensions(field));
   char *output = xasprintf("%s %s %s",
                            field? field_str(field) : "(none)",
-                           0 < dimensions(field)? subscripts : "",
+                           0 < dimensions(field)? subscripts_l : "",
                            is_refmod_reference()? "(refmod)" : "" );
   return output;
 }
@@ -1861,12 +1860,13 @@ date_time_fmt( const char input[] ) {
     { regex_t(), 'd', "^(" DATE_FMT_B "|" DATE_FMT_E ")$" },
     { regex_t(), 't', "^(" TIME_FMT_B "|" TIME_FMT_E ")$" },
   };
-  int erc, cflags = REG_EXTENDED | REG_ICASE, eflags=0;
+  int cflags = REG_EXTENDED | REG_ICASE, eflags=0;
   regmatch_t m[5];
   char result = 0;
 
   if( ! compiled ) {
     for( auto& fmt : fmts ) {
+      int erc;
       if( (erc = regcomp(&fmt.reg, fmt.pattern, cflags)) != 0 ) {
         char msg[80];
         regerror(erc, &fmt.reg, msg, sizeof(msg));
@@ -1924,7 +1924,7 @@ class unique_stack : public std::stack<input_file_t>
   friend void cobol_set_pp_option(int opt);
   bool option_m;
   std::set<std::string> all_names;
-  
+
   const char *
   no_wd( const char *wd, const char *name ) {
     int i;
@@ -1935,7 +1935,7 @@ class unique_stack : public std::stack<input_file_t>
 
  public:
   unique_stack() : option_m(false) {}
-  
+
   bool push( const value_type& value ) {
     auto ok = std::none_of( c.cbegin(), c.cend(),
                             [value]( const auto& that ) {
@@ -1969,8 +1969,8 @@ class unique_stack : public std::stack<input_file_t>
   const input_file_t& peek( size_t n ) const {
     gcc_assert( n < size() );
     return c.at(size() - ++n);
-  } 
-  
+  }
+
   void option( int opt ) { // capture other preprocessor options
eventually
     assert(opt == 'M');
     option_m = true;
@@ -1983,7 +1983,7 @@ class unique_stack : public std::stack<input_file_t>
     std::string input( top().name );
     printf( "%s: ", input.c_str() );
     for( const auto& name : all_names ) {
-      if( name != input ) 
+      if( name != input )
        printf( "\\\n\t%s ", name.c_str() );
     }
     printf("\n");
@@ -2000,7 +2000,7 @@ void cobol_set_pp_option(int opt) {
   assert(opt == 'M');
   input_filenames.option_m = true;
 }
-                                 
+
 /*
  * Maintain a stack of input filenames.  Ensure the files are unique (by
  * inode), to prevent copybook cycles. Before pushing a new name, Record
the
@@ -2011,7 +2011,7 @@ void cobol_set_pp_option(int opt) {
  * to enforce uniqueness, and the scanner to maintain line numbers.
  */
 bool cobol_filename( const char *name, ino_t inode ) {
-  const line_map *lines = NULL;
+  //const line_map *lines = NULL;
   if( inode == 0 ) {
     auto p = old_filenames.find(name);
     if( p == old_filenames.end() ) {
@@ -2021,8 +2021,10 @@ bool cobol_filename( const char *name, ino_t inode
) {
       }
       cbl_errx( "logic error: missing inode for %s", name);
     }
-    inode = p->second;
-    assert(inode != 0);
+    else {
+      inode = p->second;
+      assert(inode != 0);
+    }
   }
   linemap_add(line_table, LC_ENTER, sysp, name, 1);
   input_filename_vestige = name;
@@ -2071,7 +2073,7 @@ cobol_filename_restore() {
   input_filenames.pop();
   if( input_filenames.empty() ) return;
 
-  auto& input = input_filenames.top();
+  const auto& input = input_filenames.top();
 
   linemap_add(line_table, LC_LEAVE, sysp, NULL, 0);
 }
@@ -2083,7 +2085,7 @@ location_t location_from_lineno() { return
token_location; }
 template <typename LOC>
 static void
 gcc_location_set_impl( const LOC& loc ) {
-  // Set the position to the first line & column in the location. 
+  // Set the position to the first line & column in the location.
   token_location = linemap_line_start( line_table, loc.first_line, 80 );
   token_location = linemap_position_for_column( line_table,
loc.first_column);
   location_dump(__func__, __LINE__, "parser", loc);
@@ -2144,8 +2146,8 @@ ydferror( const char gmsgid[], ... ) {
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, token_location);
-  bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_zero,
-                                         gmsgid, &ap, DK_ERROR);
+  /*bool ret =*/ global_dc->diagnostic_impl (&richloc, nullptr,
option_zero,
+                                             gmsgid, &ap, DK_ERROR);
   va_end (ap);
 }
 
@@ -2222,8 +2224,8 @@ void error_msg_direct( const char gmsgid[], ... ) {
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  auto ret = emit_diagnostic_valist( DK_ERROR, token_location,
-                                     option_zero, gmsgid, &ap );
+  /*auto ret = */emit_diagnostic_valist( DK_ERROR, token_location,
+                                         option_zero, gmsgid, &ap );
   va_end (ap);
 }
 
@@ -2236,8 +2238,11 @@ yyerror( const char gmsgid[], ... ) {
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, token_location);
-  bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_zero,
-                                         gmsgid, &ap, DK_ERROR);
+  /*bool ret =*/ global_dc->diagnostic_impl ( &richloc,
+                                              nullptr,
+                                              option_zero,
+                                              gmsgid,
+                                              &ap, DK_ERROR);
   va_end (ap);
   global_dc->end_group();
 }
@@ -2483,8 +2488,8 @@ cbl_unimplemented_at( const YYLTYPE& loc, const char
*gmsgid, ... ) {
   va_end(ap);
 }
 
-/* 
- * analogs to err(3) and errx(3). 
+/*
+ * analogs to err(3) and errx(3).
  */
 
 #pragma GCC diagnostic push
@@ -2619,7 +2624,7 @@ static const std::set<std::string> reserved_words =
{
   "VOLATILE",
   "XML",
   "END-START",
-  
+
   // ISO 2023 keywords
   "ACCEPT",
   "ACCESS",
-- 
2.34.1


Reply via email to