<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 23, 2014 at 7:04 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Index: lib/Sema/AnalysisBasedWarnings.cpp<br>
> ===================================================================<br>
> --- lib/Sema/AnalysisBasedWarnings.cpp<br>
> +++ lib/Sema/AnalysisBasedWarnings.cpp<br>
> @@ -1025,6 +1025,9 @@<br>
> // methods separately.<br>
> bool TraverseDecl(Decl *D) { return true; }<br>
><br>
> + // We analyze lambda bodies separately. Skip them here.<br>
> + bool TraverseLambdaBody(LambdaExpr *LE) { return true; }<br>
> +<br>
> private:<br>
><br>
> static const AttributedStmt *asFallThroughAttr(const Stmt *S) {<br>
> @@ -1084,6 +1087,9 @@<br>
> if (PerFunction && FM.getFallthroughStmts().empty())<br>
> return;<br>
><br>
> + llvm::errs() << "DiagnoseSwitchLabelsFallthrough: \n";<br>
> + AC.getBody()->dumpColor();<br>
<br>
This looks like debugging code that should likely go away.<br></blockquote><div><br></div><div>Sure, removed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> +<br>
> CFG *Cfg = AC.getCFG();<br>
><br>
> if (!Cfg)<br>
> Index: test/SemaCXX/switch-implicit-fallthrough.cpp<br>
> ===================================================================<br>
> --- test/SemaCXX/switch-implicit-fallthrough.cpp<br>
> +++ test/SemaCXX/switch-implicit-fallthrough.cpp<br>
> @@ -229,25 +229,6 @@<br>
> return n;<br>
> }<br>
><br>
> -int fallthrough_targets(int n) {<br>
> - [[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}}<br>
> -<br>
> - [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}}<br>
> - switch (n) {<br>
> - case 121:<br>
> - n += 400;<br>
> - [[clang::fallthrough]]; // no warning here, correct target<br>
> - case 123:<br>
> - [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}}<br>
> - n += 800;<br>
> - break;<br>
> - [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} expected-note{{did you forget ';'?}}<br>
> - case 125:<br>
> - n += 1600;<br>
> - }<br>
> - return n;<br>
> -}<br>
<br>
Why did this test move within the file?<br></blockquote><div><br></div><div>Clang seems to stop producing warnings after the function containing errors, so the test with errors should be the last one (or maybe even in a separate file).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> -<br>
> // Fallthrough annotations in local classes used to generate "fallthrough<br>
> // annotation does not directly precede switch label" warning.<br>
> void fallthrough_in_local_class() {<br>
> @@ -259,12 +240,34 @@<br>
> [[clang::fallthrough]]; // no diagnostics<br>
> case 1:<br>
> x++;<br>
> + default: // \<br>
> + expected-warning{{unannotated fall-through between switch labels}} \<br>
> + expected-note{{insert 'break;' to avoid fall-through}}<br>
> break;<br>
> }<br>
> }<br>
> };<br>
> }<br>
><br>
> +// Fallthrough annotations in lambdas used to generate "fallthrough<br>
> +// annotation does not directly precede switch label" warning.<br>
> +void fallthrough_in_lambda() {<br>
> + (void)[] {<br>
> + int x = 0;<br>
> + switch (x) {<br>
> + case 0:<br>
> + x++;<br>
> + [[clang::fallthrough]]; // no diagnostics<br>
> + case 1:<br>
> + x++;<br>
> + default: // \<br>
> + expected-warning{{unannotated fall-through between switch labels}} \<br>
> + expected-note{{insert 'break;' to avoid fall-through}}<br>
> + break;<br>
> + }<br>
> + };<br>
> +}<br>
> +<br>
> namespace PR18983 {<br>
> void fatal() __attribute__((noreturn));<br>
> int num();<br>
> @@ -278,3 +281,22 @@<br>
> }<br>
> }<br>
> }<br>
> +<br>
> +int fallthrough_targets(int n) {<br>
> + [[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}}<br>
> +<br>
> + [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}}<br>
> + switch (n) {<br>
> + case 121:<br>
> + n += 400;<br>
> + [[clang::fallthrough]]; // no warning here, correct target<br>
> + case 123:<br>
> + [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}}<br>
> + n += 800;<br>
> + break;<br>
> + [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} expected-note{{did you forget ';'?}}<br>
> + case 125:<br>
> + n += 1600;<br>
> + }<br>
> + return n;<br>
> +}<br>
><br>
<br>
~Aaron<br>
<div><div class="h5"><br>
On Mon, Jun 23, 2014 at 11:23 AM, Alexander Kornienko <<a href="mailto:alexfh@google.com">alexfh@google.com</a>> wrote:<br>
> Hi rsmith,<br>
><br>
> <a href="http://reviews.llvm.org/D4258" target="_blank">http://reviews.llvm.org/D4258</a><br>
><br>
> Files:<br>
> lib/Sema/AnalysisBasedWarnings.cpp<br>
> test/SemaCXX/switch-implicit-fallthrough.cpp<br></div></div></blockquote></div>
</div></div>