<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - -Wunreachable-code complains about silenced code"
   href="https://bugs.llvm.org/show_bug.cgi?id=39736">39736</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wunreachable-code complains about silenced code
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>akim.demaille@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21136" name="attach_21136" title="generated output">attachment 21136</a> <a href="attachment.cgi?id=21136&action=edit" title="generated output">[details]</a></span>
generated output

I was unable to make a smaller example that still shows the problem, this
happens in code generated by GNU Bison.

The core of the generated parser is a state machine implemented with labels and
gotos.  Some of the labels might not be used, depending on the what the user
does in her actions, so to avoid warning about unreachable code, there's

yyerrorlab:
  /* Pacify compilers like GCC when the user code never invokes
     YYERROR and the label yyerrorlab therefore never appears in user
     code.  */
  if ((0))
    goto yyerrorlab;

With -Wunreachable-code, clang still complains about this `if (0)`:

$ clang-mp-7.0 foo.tab.c -Wunreachable-code
foo.tab.c:1302:5: warning: code will never be executed [-Wunreachable-code]
    goto yyerrorlab;
    ^~~~~~~~~~~~~~~
foo.tab.c:1301:8: note: silence by adding parentheses to mark code as
explicitly dead
  if ((0))
       ^
       /* DISABLES CODE */ ( )
1 warning generated.

I have this problem with all the versions of Clang I can run:

$ clang-mp-3.9 --version | sed 1q
clang version 3.9.1 (tags/RELEASE_391/final)
$ clang-mp-4.0 --version | sed 1q
clang version 4.0.1 (tags/RELEASE_401/final)
$ clang-mp-5.0 --version | sed 1q
clang version 5.0.2 (tags/RELEASE_502/final)
$ clang-mp-7.0 --version | sed 1q
clang version 7.0.0 (tags/RELEASE_700/final)
$ clang-mp-devel --version | sed 1q
clang version 8.0.0 (trunk 340138)


I attached the generated output.  The input file is below.

Cheers!


%{
  int yylex (void)
  {
    return 0;
  }

  void yyerror (char const *s)
  {}
%}
%%
input:
%%
int main (void)
{
  return yyparse ();
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>