public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ?
@ 2022-07-20 11:32 dcb314 at hotmail dot com
  2022-07-21 11:56 ` [Bug c/106370] " marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2022-07-20 11:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106370

            Bug ID: 106370
           Summary: enhancement: last statement of loop is continue is
                    redundant ?
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Cppcheck has just been enhanced to detect the last statement of
a loop is a continue and mark it as a bad style. 

For example:

gcc/cp/init.cc:1439:4: style: 'continue' is redundant since it is the last
statement in a loop. [redundantContinue]

Source code is

    splice:
      *p = TREE_CHAIN (*p);
      continue;
    }

I feel this is a minor style issue which gcc may not be interested in,
but I thought it best to make others aware.

21 cases in the gcc source code. List available.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/106370] enhancement: last statement of loop is continue is redundant ?
  2022-07-20 11:32 [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ? dcb314 at hotmail dot com
@ 2022-07-21 11:56 ` marxin at gcc dot gnu.org
  2022-07-21 20:34 ` dcb314 at hotmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-21 11:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106370

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-07-21
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Please provide the list, I'll remove the statements.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/106370] enhancement: last statement of loop is continue is redundant ?
  2022-07-20 11:32 [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ? dcb314 at hotmail dot com
  2022-07-21 11:56 ` [Bug c/106370] " marxin at gcc dot gnu.org
@ 2022-07-21 20:34 ` dcb314 at hotmail dot com
  2022-07-22  7:30 ` [Bug other/106370] " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2022-07-21 20:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106370

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---

The list is:

trunk.git/gcc/config/mcore/mcore.cc:2610:5: style: 'continue' is redundant
since it is the last statement in a loop. [redundantContinue]
trunk.git/gcc/config/nvptx/mkoffload.cc:273:7: style: 'continue' is redundant
since it is the last statement in a loop. [redundantContinue]
trunk.git/gcc/config/rs6000/rs6000-logue.cc:752:2: style: 'continue' is
redundant since it is the last statement in a loop. [redundantContinue]
trunk.git/gcc/cp/init.cc:1439:4: style: 'continue' is redundant since it is the
last statement in a loop. [redundantContinue]
trunk.git/gcc/cp/search.cc:2400:5: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/gcc/cp/search.cc:2625:2: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/gcc/gcov-io.cc:162:5: style: 'continue' is redundant since it is the
last statement in a loop. [redundantContinue]
trunk.git/gcc/vector-builder.h:583:2: style: 'continue' is redundant since it
is the last statement in a loop. [redundantContinue]
trunk.git/gcc/vector-builder.h:602:6: style: 'continue' is redundant since it
is the last statement in a loop. [redundantContinue]
/usr/local/share/bison/bison.simple:281:5: style: 'continue' is redundant since
it is the last statement in a loop. [redundantContinue]
/usr/local/share/bison/bison.simple:307:5: style: 'continue' is redundant since
it is the last statement in a loop. [redundantContinue]
trunk.git/libcpp/mkdeps.cc:309:2: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/libgomp/config/linux/sem.h:81:5: style: 'continue' is redundant since
it is the last statement in a loop. [redundantContinue]
trunk.git/libgomp/config/posix/sem.c:142:5: style: 'continue' is redundant
since it is the last statement in a loop. [redundantContinue]
trunk.git/libiberty/_doprnt.c:87:2: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/libiberty/_doprnt.c:194:8: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/libiberty/argv.c:515:5: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/libiberty/pex-win32.c:593:9: style: 'continue' is redundant since it
is the last statement in a loop. [redundantContinue]
trunk.git/libiberty/pex-win32.c:701:3: style: 'continue' is redundant since it
is the last statement in a loop. [redundantContinue]
trunk.git/libitm/aatree.cc:175:2: style: 'continue' is redundant since it is
the last statement in a loop. [redundantContinue]
trunk.git/libitm/clone.cc:179:7: style: 'continue' is redundant since it is the
last statement in a loop. [redundantContinue]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/106370] enhancement: last statement of loop is continue is redundant ?
  2022-07-20 11:32 [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ? dcb314 at hotmail dot com
  2022-07-21 11:56 ` [Bug c/106370] " marxin at gcc dot gnu.org
  2022-07-21 20:34 ` dcb314 at hotmail dot com
@ 2022-07-22  7:30 ` cvs-commit at gcc dot gnu.org
  2022-07-22  7:31 ` marxin at gcc dot gnu.org
  2022-07-25 13:30 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-22  7:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106370

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:aaf9583d4cf048850b1eb74d25866f45198e35b8

commit r13-1792-gaaf9583d4cf048850b1eb74d25866f45198e35b8
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Jul 22 09:28:48 2022 +0200

    remove 'continue' as last statement in loop

            PR other/106370

    gcc/cp/ChangeLog:

            * init.cc (sort_mem_initializers): Remove continue as last stmt
            in a loop.

    libiberty/ChangeLog:

            * _doprnt.c: Remove continue as last stmt
            in a loop.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/106370] enhancement: last statement of loop is continue is redundant ?
  2022-07-20 11:32 [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ? dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2022-07-22  7:30 ` [Bug other/106370] " cvs-commit at gcc dot gnu.org
@ 2022-07-22  7:31 ` marxin at gcc dot gnu.org
  2022-07-25 13:30 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-22  7:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106370

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixes 2 locations, for the rest it seems fine to me the way we write empty body
loop:

  for (insn = get_insns (); insn; insn = conditionalize_block (insn))
    continue;

The warning should be omitted when the only statement in a loop in 'continue'.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug other/106370] enhancement: last statement of loop is continue is redundant ?
  2022-07-20 11:32 [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ? dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2022-07-22  7:31 ` marxin at gcc dot gnu.org
@ 2022-07-25 13:30 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2022-07-25 13:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106370

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
The use in cp/init.cc also seemed reasonable to me; the loop body had two
blocks starting with a label and ending with continue; that one of them
happened to be the last statement of the block was coincidence.  But removing
it is also fine, I guess.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-25 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 11:32 [Bug c/106370] New: enhancement: last statement of loop is continue is redundant ? dcb314 at hotmail dot com
2022-07-21 11:56 ` [Bug c/106370] " marxin at gcc dot gnu.org
2022-07-21 20:34 ` dcb314 at hotmail dot com
2022-07-22  7:30 ` [Bug other/106370] " cvs-commit at gcc dot gnu.org
2022-07-22  7:31 ` marxin at gcc dot gnu.org
2022-07-25 13:30 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).