What's the recommended method in GnuCOBOL to suppress certain superfluous warning messages? An example is if I have a call statement like:
CALL "SUB" USING PARM,
DUMMY,
DUMMY,
DUMMY.
it gets flagged with warnings like "warning: duplicate USING BY REFERENCE item 'DUMMY' [-Wothers]" even though I've used that with many other COBOL compilers over the years. It doesn't seem to have an effect on the compiled code. I'm just a bit picky about getting warnings for what's otherwise valid code.
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What's the recommended method in GnuCOBOL to suppress certain superfluous warning messages?
Intro: each warning has an option, with a "recent" version (not older than 2021) it is shown in the message - in your case [-Wother] the option name is other.
The two options "other" and "additional" are special cases as they group a bunch of different issues where there wasn't seen a reason (yet) to use a separate option; check NEWS when changing the version, it will tell about adjusted warning options (new and split warning options and in theory dropped ones, which did not happen so far).
understand what the message is about and why it is there; cobc --help or the manual - which contains its output formatted - have a description, a search with the option name in this discussion board or on the net often helps, too
check if it is a good idea to ignore it (for example things like missing terminators are likely be seen as style issue); the default warnings are a reasonable subset, ignoring these should be an educated decision; the subset of -Wall are still things to consider twice, -Wextra (or previous -W) is mostly useful if you inspect programs with strange results; and in any case you may even find that for your style/house rules you want to increase a specific warning to an error with -Werror=option
handle the message:
fix the actual code, either manual or with conversion program (commonly even a sed is enough)
disable by name, so in this case -Wno-other
in your post-compile / warning check procedures drop/ignore that warning (this may be quite specific, like in your case only doing so if it contains "DUMMY")
change cobc to not raise this specific warning at all
For this specific message, which we just discussed in [64b12f8a19]:
PROCEDURE DIVISION USING VAR-1, VAR-2, VAR-2, VAR-2 - same variable in a called program on more than one place - is explicit forbidden. Doing a CALL PROG USING PARM, DUMMY, DUMMY, DUMMY is effectively doing that from the caller.
COBOL has the language feature to specify OMITTED for a parameter which is not to be passed, this solves most of the issues (of course the called program should then not use this parameter other than a potential IF PARM-2 IS [NOT] OMITTED).
... if you still want to disable it, as mentioned in 3.2: compile with -Wno-other (but as mentioned in the intro "other" groups a bunch of warnings, you may want to check in the compiler's sources of your specific version for COBC_WARN_FILLER to see what it is used for, before disabling all of these).
It's relatively dangerous, as it's so easy to over use, but if you know know that all the warnings you're seeing are superfluous to the current round of edit compile link go repeat iterations, and for completeness, cobc -w. little w. No warnings. None. Only recommended for short bursts or programming in the small or experimental. -Wall and fixes being the better way for work COBOL. ;-)
In the case at hand, it's a warning you'd usually want to see when passing addresses of writable fields ... but -w comes in handy at times.
Cheers,
Blue
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What's the recommended method in GnuCOBOL to suppress certain superfluous warning messages? An example is if I have a call statement like:
it gets flagged with warnings like "warning: duplicate USING BY REFERENCE item 'DUMMY' [-Wothers]" even though I've used that with many other COBOL compilers over the years. It doesn't seem to have an effect on the compiled code. I'm just a bit picky about getting warnings for what's otherwise valid code.
Thanks in advance.
Intro: each warning has an option, with a "recent" version (not older than 2021) it is shown in the message - in your case
[-Wother]the option name isother.The two options "other" and "additional" are special cases as they group a bunch of different issues where there wasn't seen a reason (yet) to use a separate option; check NEWS when changing the version, it will tell about adjusted warning options (new and split warning options and in theory dropped ones, which did not happen so far).
cobc --helpor the manual - which contains its output formatted - have a description, a search with the option name in this discussion board or on the net often helps, too-Wallare still things to consider twice,-Wextra(or previous-W) is mostly useful if you inspect programs with strange results; and in any case you may even find that for your style/house rules you want to increase a specific warning to an error with-Werror=optionsedis enough)-Wno-otherFor this specific message, which we just discussed in [64b12f8a19]:
PROCEDURE DIVISION USING VAR-1, VAR-2, VAR-2, VAR-2- same variable in a called program on more than one place - is explicit forbidden. Doing aCALL PROG USING PARM, DUMMY, DUMMY, DUMMYis effectively doing that from the caller.COBOL has the language feature to specify
OMITTEDfor a parameter which is not to be passed, this solves most of the issues (of course the called program should then not use this parameter other than a potentialIF PARM-2 IS [NOT] OMITTED).... if you still want to disable it, as mentioned in 3.2: compile with
-Wno-other(but as mentioned in the intro "other" groups a bunch of warnings, you may want to check in the compiler's sources of your specific version forCOBC_WARN_FILLERto see what it is used for, before disabling all of these).Related
Discussion: 64b12f8a19
It's relatively dangerous, as it's so easy to over use, but if you know know that all the warnings you're seeing are superfluous to the current round of edit compile link go repeat iterations, and for completeness,
cobc -w. little w. No warnings. None. Only recommended for short bursts or programming in the small or experimental.-Walland fixes being the better way for work COBOL. ;-)In the case at hand, it's a warning you'd usually want to see when passing addresses of writable fields ... but
-wcomes in handy at times.Cheers,
Blue