> -----Original Message-----
> From: Jakub Jelinek <ja...@redhat.com>
> Sent: Friday, August 1, 2025 12:47
> To: Robert Dubner <rdub...@symas.com>
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [committed] cobol: Minor changes to quiet cppcheck
warnings.
> [PR119324]
>
> On Fri, Aug 01, 2025 at 11:39:34AM -0500, Robert Dubner wrote:
> > --- a/gcc/cobol/genutil.cc
> > +++ b/gcc/cobol/genutil.cc
> > @@ -27,6 +27,9 @@
> > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE
> > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
> > */
> > +
> > +// cppcheck-suppress-file duplicateBreak
> > +
> > #include "cobol-system.h"
> > #include "coretypes.h"
> > #include "tree.h"
> > @@ -1267,7 +1270,7 @@ get_binary_value( tree value,
> > cbl_field_type_str(field->type) );
> > cbl_internal_error("%s", err);
> > abort();
> > - // break; // break not needed after abort();
> > + break;
>
> Why? Just drop the break. break isn't needed at the end of a switch
> anyway. And abort is noreturn.
Jim and I had this exact same discussion. It's a matter of style. In
that code, Jim has "return" statements scattered among the case
statements. Some of those breaks would be necessary if the code ending in
return were to be changed so as to end in return. I personally don't
often put return statements in the middle of functions; I prefer to have
one at the end. Jim is more comfortable with returns in the middle. But
we are both happier when case statements always end with a break,
necessary or not.
>
> > @@ -500,13 +502,13 @@ symbol_elem_cmp( const void *K, const void *E )
> > }
> > return strcasecmp(key.name, elem.name);
> > }
> > - // break; // This break not needed if all options do a return.
> > + break;
> > case SymSpecial:
> > return special_pair_cmp(k->elem.special, e->elem.special)? 0 : 1;
> > - // break; // This break not needed after return.
> > + break;
> > case SymAlphabet:
> > return strcasecmp(k->elem.alphabet.name, e->elem.alphabet.name);
> > - // break; // This break not needed after return.
> > + break;
> > 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 +516,7 @@ symbol_elem_cmp( const void *K, const void *E )
> > return 1;
> > }
> > return strcasecmp(k->elem.file.name, e->elem.file.name);
> > - // break; // This break not needed after return.
> > + break;
> > }
>
> Similarly for all of these, break after return is just unneeded extra
> clutter, plus we have the -Wimplicit-fallthrough warning on, so if one
> case would for whatever reason fall through into another one without
magic
> comment or [[fallthrough]]; attribute etc., we'd get warnings on it.
>
> Jakub