Hi all,<div><br></div><div>This patch adds diagnostic of unintentional control flow fall-through between switch labels. It also provides a way to specifically mark a switch label with a c++ 11 attribute [[fallthrough]] to specify an intentional fall-through. This also serves as an example of C++ 11 statement attributes, and builds upon my recent patch, which introduces support for this language feature.</div>
<div><br></div><div>This diagnostic is can be turned on using -Wimplicit-fallthrough option (off by-default). The patch contains a test case (test/SemaCXX/switch-implicit-fallthrough.cpp).</div><div><div><br></div><div>Example:</div>
<div>compile this code with -c -std=c++11 -Wimplicit-fallthrough</div><div><br></div><div><font color="#222222" face="monospace"><span style="white-space:pre"><b>int f(int n) {
  int t = 0;
  switch (n) {
  case 1:
    t = n;
  case 2:
    t = 2 * n;
    break;
  }
  return t;
}</b></span></font> <pre class="code" style="color:rgb(34,34,34);background-color:rgb(255,255,255)"><span style="font-family:arial,helvetica,sans-serif">Compiler will emit a similar warning:</span></pre><font color="#222222" face="arial, helvetica, sans-serif"><span style="white-space:pre">test.cpp:6:3: warning: missing 'break' or 'return' statement; use [[fallthrough]] attribute to silence this warning [-Wimplicit-fallthrough]
  case 2:
  ^
  [[fallthrough]]</span></font> <pre class="code" style="background-color:rgb(255,255,255)"><font color="#222222" face="arial, helvetica, sans-serif">Then add </font><span style="color:rgb(34,34,34);font-family:arial,helvetica,sans-serif;background-color:transparent">[[fallthrough]] before "case 2:" and recompile. Warning will not be issued.</span></pre>
<pre class="code" style="background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,helvetica,sans-serif;background-color:transparent">Please, review this patch.</span></pre><pre class="code" style="background-color:rgb(255,255,255)">
<font color="#222222" face="arial, helvetica, sans-serif">Thanks!</font></pre><pre class="code" style="background-color:rgb(255,255,255)"><font color="#222222" face="arial, helvetica, sans-serif"><br></font></pre></div>-- <br>

<div>Best regards,</div><div>Alexander Kornienko</div></div>