<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Experiment with a -Windent warning"
   href="http://llvm.org/bugs/show_bug.cgi?id=18938">18938</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Experiment with a -Windent warning
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12113" name="attach_12113" title="prototype patch v0">attachment 12113</a> <a href="attachment.cgi?id=12113&action=edit" title="prototype patch v0">[details]</a></span>
prototype patch v0

Wouldn't it be great if clang warned on something like

  if (5 != 0)
    goto fail;
    goto fail;

?

This bug tracks various ideas for warnings about this based on indent level.
(There's already -Wunreachable-code for the CFG approach).

Version 1: Remember only child of unbraced ifs, fors, whiles, and warn if next
statement has same indent as that child. Prototype patch attached (it doesn't
reset IndentStmt often enough).

It has false positives on this code in udis86.c in mach_override:

  if (ud_input_end(u))
  return 0;

  u->asm_buf[0] = 0;

  if (ud_decode(u) == 0)
  return 0;


Also on this from mach_override.c, but looking at the style in the rest of the
file that might actually be a (harmless) true positive:

    if( !err )    
        err = allocateBranchIsland( &escapeIsland, kAllocateHigh,
originalFunctionAddress );
        if (err) fprintf(stderr, "err = %x %s:%d\n", err, __FILE__, __LINE__);</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>