[Webkit-unassigned] [Bug 127637] Add FALLTHROUGH and -Wimplicit-fallthrough to warn about unannotated implicit fallthroughs in switches

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Jan 25 19:15:29 PST 2014


https://bugs.webkit.org/show_bug.cgi?id=127637


Joseph Pecoraro <joepeck at webkit.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |darin at apple.com,
                   |                            |joepeck at webkit.org




--- Comment #6 from Joseph Pecoraro <joepeck at webkit.org>  2014-01-25 19:12:54 PST ---
There is an advantage to defining the macro without a semicolon. Clang detects if is a macro with the exact text of the fall through extension. So when it emits a warning it suggests using the macro in the build warning:

With: #define FALLTHROUGH [[clang::fallthrough]]

    CompileC wtf/dtoa/fast-dtoa.cc
    /Users/pecoraro/Code/webkit/Source/WTF/wtf/dtoa/fast-dtoa.cc:258:13: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                case 29:
                ^
    /Users/pecoraro/Code/webkit/Source/WTF/wtf/dtoa/fast-dtoa.cc:258:13: note: insert 'FALLTHROUGH;' to silence this warning
                case 29:
                ^
>                FALLTHROUGH; 
    /Users/pecoraro/Code/webkit/Source/WTF/wtf/dtoa/fast-dtoa.cc:258:13: note: insert 'break;' to avoid fall-through
                case 29:
                ^
                break; 
    1 error generated.


However, if the macro is not an exact match, e.g. includes a semicolon, the warning doesn't mention the macro at all:

#define FALLTHROUGH [[clang::fallthrough]];

    CompileC wtf/dtoa/fast-dtoa.cc
    /Users/pecoraro/Code/webkit/Source/WTF/wtf/dtoa/fast-dtoa.cc:258:13: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
                case 29:
                ^
    /Users/pecoraro/Code/webkit/Source/WTF/wtf/dtoa/fast-dtoa.cc:258:13: note: insert '[[clang::fallthrough]];' to silence this warning
                case 29:
                ^
>                [[clang::fallthrough]]; 
    /Users/pecoraro/Code/webkit/Source/WTF/wtf/dtoa/fast-dtoa.cc:258:13: note: insert 'break;' to avoid fall-through
                case 29:
                ^
                break; 
    1 error generated.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list