On 12/9/21 3:58 PM, Jim Wilson wrote:
On Mon, Nov 29, 2021 at 5:21 PM Martin Sebor via Gcc-patches <gcc-patches@gcc.gnu.org <mailto:gcc-patches@gcc.gnu.org>> wrote:

    There are some other "unusual" cases worth a look, such as missing
    context of any kind except for like and column:

    elfnn-riscv.c:3346:7: warning: statement after return is not reachable
    [-Wunreachable-code-return]
    elfnn-riscv.c:3349:7: warning: statement after return is not reachable
    [-Wunreachable-code-return]
    elfnn-riscv.c:3352:7: warning: statement after return is not reachable
    [-Wunreachable-code-return]
    elfnn-riscv.c:3355:7: warning: statement after return is not reachable
    [-Wunreachable-code-return]


That file has "return ...; break;" inside a switch.  Warning for that is OK, and we shouldn't need a better warning message.  It is pretty obvious what is wrong.

Yes, it's obvious from code inspection.  What I meant is that
the warnings above don't show the code they refer to as other
messages do, like on the second line in:

/src/binutils-gdb/bfd/elf-attrs.c:450:7: warning: statement after return is not reachable [-Wunreachable-code-return]
  450 |       break;
      |       ^~~~~

If they did, no code inspection would be necessary to understand
that the warnings are valid and why (I suggested elsewhere to
add a note pointing to the statement that makes the one in
the warning unreachable; that would help in cases when the first
statement is obscured by a macro, for instance, or far away from
the warning site).

The above were the only warnings I saw in the Binutils build with
this problem (or ever, that I can think of).

Martin

Reply via email to