]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Variety of small changes in answer to cppcheck diagnostics.
authorJames K. Lowden <jklowden@cobolworx.com>
Tue, 10 Jun 2025 14:34:28 +0000 (10:34 -0400)
committerRobert Dubner <rdubner@symas.com>
Tue, 29 Jul 2025 16:06:39 +0000 (12:06 -0400)
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)

gcc/cobol/Make-lang.in
gcc/cobol/cdf.y
gcc/cobol/cdfval.h
gcc/cobol/gcobol.1
gcc/cobol/gcobolspec.cc
gcc/cobol/parse_ante.h

index 993e4c6ffb023c4a60a476810e7d28a33336cf73..5f293e1f9874a440c5067f0e995bc6c693e13c4e 100644 (file)
@@ -351,8 +351,7 @@ cobol.srcman:
 cobol.mostlyclean:
 
 cobol.clean:
-       rm -fr gcobol cobol1 cobol/*            \
-       ../*/libgcobol/*
+       rm -fr gcobol cobol1 cobol/*
 
 cobol.distclean:
 
index 0440d0216af97e016001ae54f49a3d6a2115e48c..e4d2feaaf52eb266f322497bdf9fbfc80fdd13eb 100644 (file)
@@ -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);
index 09c21ab08e504e97805afbabe92c3102044de5ea..c4387b08066161324763b4a101fd76da270d3db9 100644 (file)
 
 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;
index 0ce890e97229b2fab58eda1da0e2019c1b92b152..6db54009fcf7bd356abd80bac3143aee86a645dc 100644 (file)
@@ -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 cant 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.  Its 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 dont
+implementations of floating-point conversions and comparisons don't
 precisely match the behavior of other \*[lang] compilers.
 .Pp
 You have been warned.
index d1ffc97f8ca5ebcdba4e934787d9e970547f433b..70784d7e3570c41db81d4cd4c20486b294b4cbfb 100644 (file)
@@ -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;
index f62a2f1a534b7565e4fff72c84c4c436f4bd388e..22ce612a2e8a0ffc5c5fc612e43183b9876a5a52 100644 (file)
@@ -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<cbl_refer_t> args { *r1, *r2 };
+  std::vector<cbl_refer_t> 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);