Nope! If there is no statement between case labels, there will be no warning.

Follow the link for a more complete description of cases:
<http://clang.llvm.org/docs/LanguageExtensions.html#the-clang-fallthrough-attribute>

- Joe

On Jan 26, 2014, at 10:23 AM, Brady Eidson <beid...@apple.com> wrote:

> I like this!
> 
> Out of curiosity, will it be needed for cases like:
> 
> switch (input) {
> case 1:  // fallthrough?
> case 2:
>     // Handle both 1 and 2
>     break;
> default:
>     // default
> }
> 
> Thanks,
> ~Brady
> 
> On Jan 26, 2014, at 1:41 AM, Joseph Pecoraro <pecor...@apple.com> wrote:
> 
>> Hello!
>> 
>> I'm slowly enabling -Wimplicit-fallthrough on projects in the Mac / iOS 
>> ports.
>> <http://trac.webkit.org/changeset/162793>
>> <http://clang.llvm.org/docs/LanguageExtensions.html#the-clang-fallthrough-attribute>
>> 
>> This means that if you write any switch statements with implicit 
>> fallthroughs it will produce build errors in projects with the warning 
>> enabled.
>> 
>> If you're writing a switch with a fallthrough, use the "FALLTHROUGH;" 
>> annotation (which expands to [[clang::fallthrough]];) to appease the warning.
>> 
>> The intent of this warning is to catch at compile time any accidental switch 
>> fallthroughs, and therefore explicitly annotate everywhere a fallthrough was 
>> intended.
>> 
>> Thanks,
>> - JoePeck
>> 
>> --
>> 
>> For example. Here is a switch with an implicit fallthrough but no compiler 
>> recognized annotation:
>> 
>> switch (input) {
>> case 1:
>>     output -= 5;
>>     // fallthrough
>> default:
>>     output += 5;
>> }
>> 
>> When the warning is enabled you will see a build error like:
>> 
>> main.cpp:9:5: warning: unannotated fall-through between switch labels 
>> [-Wimplicit-fallthrough]
>>     default:
>>     ^
>> main.cpp:9:5: note: insert 'FALLTHROUGH;' to silence this warning
>>     default:
>>     ^
>>     FALLTHROUGH; 
>> main.cpp:9:5: note: insert 'break;' to avoid fall-through
>>     default:
>>     ^
>>     break; 
>> 
>> Use "FALLTHROUGH;" to annotate the fallthrough and build without errors:
>> 
>> switch (input) {
>> case 1:
>>     output -= 5;
>>     FALLTHROUGH;
>> default:
>>     output += 5;
>> }
>> 
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to