From: James K. Lowden Date: Tue, 10 Jun 2025 14:34:28 +0000 (-0400) Subject: cobol: Variety of small changes in answer to cppcheck diagnostics. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f79a7d0f7b3f79c8e234ca870c0abf5b3101368e;p=thirdparty%2Fgcc.git cobol: Variety of small changes in answer to cppcheck diagnostics. Remove non-ASCII input and blank lines from gcobol.1. Restrict cobol.clean target to compiler object files. gcc/cobol/ChangeLog: * Make-lang.in: cobol.clean does not remove libgcobol files. * cdf.y: Suppress 1 cppcheck false positive. * cdfval.h (scanner_parsing): Partial via cppcheck for PR119324. * gcobol.1: Fix groff errors. * gcobolspec.cc (append_arg): Const parameter. * parse_ante.h (intrinsic_call_2): Avoid NULL dereference. (cherry picked from commit 70c3dd9a81cdefcaf24a66ec0c1ceddf5d3984dd) --- diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in index 993e4c6ffb0..5f293e1f987 100644 --- a/gcc/cobol/Make-lang.in +++ b/gcc/cobol/Make-lang.in @@ -351,8 +351,7 @@ cobol.srcman: cobol.mostlyclean: cobol.clean: - rm -fr gcobol cobol1 cobol/* \ - ../*/libgcobol/* + rm -fr gcobol cobol1 cobol/* cobol.distclean: diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y index 0440d0216af..e4d2feaaf52 100644 --- a/gcc/cobol/cdf.y +++ b/gcc/cobol/cdf.y @@ -891,6 +891,7 @@ verify_integer( const YDFLTYPE& loc, const cdfval_base_t& val ) { return true; } +// cppcheck-suppress returnTempReference const cdfval_base_t& cdfval_base_t::operator()( const YDFLTYPE& loc ) { static cdfval_t zero(0); diff --git a/gcc/cobol/cdfval.h b/gcc/cobol/cdfval.h index 09c21ab08e5..c4387b08066 100644 --- a/gcc/cobol/cdfval.h +++ b/gcc/cobol/cdfval.h @@ -38,6 +38,14 @@ bool scanner_parsing(); +/* cdfval_base_t has no constructor because otherwise: + * cobol/cdf.h:172:7: note: ‘YDFSTYPE::YDFSTYPE()’ is implicitly deleted + * because the default definition would be ill-formed: + * 172 | union YDFSTYPE + * + * We use the derived type cdfval_t, which can be properly constructed and + * operated on, but tell Bison only about its POD base class. + */ struct YDFLTYPE; struct cdfval_base_t { bool off; diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1 index 0ce890e9722..6db54009fcf 100644 --- a/gcc/cobol/gcobol.1 +++ b/gcc/cobol/gcobol.1 @@ -39,7 +39,7 @@ compiles \*[lang] source code to object code, and optionally produces an executable binary or shared object. As a GCC component, it accepts all options that affect code-generation and linking. Options specific to \*[lang] are listed below. -.Bl -tag -width \0\0debug +.Bl -tag -width "\0\0debug" .It Fl main Ar filename .Nm will generate a @@ -197,14 +197,12 @@ Otherwise, columns 1-6 are examined. If those characters are all digits or blanks, the file is assumed to be in .Em "fixed-form reference format", also with the indicator in column 7. - If not auto-detected as .Em "fixed-form reference format" or .Em "extended source format", the file is assumed to be in .Em "free-form reference format". - .Pp . .It Fl fcobol-exceptions Ar exception Op Ns , Ns Ar exception Ns ... @@ -1088,7 +1086,7 @@ the directive must appear before .Pp To test a feature-set variable, use .Dl >>IF Ar feature Li DEFINED -.. +. .Ss Copybooks .Nm supports the CDF @@ -1294,7 +1292,7 @@ stores and converts numbers. Converting the floating-point value to the numeric display value 0055110 is done by multiplying 55.109999...\& by 1,000 and then truncating the result to an integer. And it turns out that even -though 55.11 can’t be represented in floating-point as an exact value, +though 55.11 can't be represented in floating-point as an exact value, the product of the multiplication, 55110, is an exact value. .Pp In cases where it is important for conversions to have predictable @@ -1325,7 +1323,7 @@ specified for a calculation, then the intermediate result becomes a . .Ss A warning about binary floating point comparison The cardinal rule when doing comparisons involving floating-point -values: Never, ever, test for equality. It’s just not worth the hassle. +values: Never, ever, test for equality. It's just not worth the hassle. .Pp For example: .Bd -literal @@ -1361,7 +1359,7 @@ and you really test the code. And then avoid it anyway. .Pp Finally, it is observably the case that the .Nm -implementations of floating-point conversions and comparisons don’t +implementations of floating-point conversions and comparisons don't precisely match the behavior of other \*[lang] compilers. .Pp You have been warned. diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc index d1ffc97f8ca..70784d7e357 100644 --- a/gcc/cobol/gcobolspec.cc +++ b/gcc/cobol/gcobolspec.cc @@ -82,7 +82,7 @@ static bool need_libgcobol = true; // #define NOISY 1 static void -append_arg(const struct cl_decoded_option arg) +append_arg(const cl_decoded_option& arg) { #ifdef NOISY static int counter = 1; diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index f62a2f1a534..22ce612a2e8 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -2612,7 +2612,7 @@ intrinsic_call_1( cbl_field_t *output, int token, static bool intrinsic_call_2( cbl_field_t *tgt, int token, cbl_refer_t *r1, cbl_refer_t *r2 ) { - std::vector args { *r1, *r2 }; + std::vector args { *r1, r2? *r2 : cbl_refer_t() }; size_t n = intrinsic_invalid_parameter(token, args); if( n < args.size() ) { error_msg(args[n].loc, "invalid parameter '%s'", args[n].field->name);