Re: [webkit-dev] Heads up: FALLTHROUGH annotations for switches with fallthroughs

2014-01-26 Thread Joseph Pecoraro
Nope! If there is no statement between case labels, there will be no warning.

Follow the link for a more complete description of cases:


- Joe

On Jan 26, 2014, at 10:23 AM, Brady Eidson  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  wrote:
> 
>> Hello!
>> 
>> I'm slowly enabling -Wimplicit-fallthrough on projects in the Mac / iOS 
>> ports.
>> 
>> 
>> 
>> 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


Re: [webkit-dev] Heads up: FALLTHROUGH annotations for switches with fallthroughs

2014-01-26 Thread Brady Eidson
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  wrote:

> Hello!
> 
> I'm slowly enabling -Wimplicit-fallthrough on projects in the Mac / iOS ports.
> 
> 
> 
> 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


[webkit-dev] Heads up: FALLTHROUGH annotations for switches with fallthroughs

2014-01-26 Thread Joseph Pecoraro
Hello!

I'm slowly enabling -Wimplicit-fallthrough on projects in the Mac / iOS ports.



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