WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
127637
Add FALLTHROUGH and -Wimplicit-fallthrough to warn about unannotated implicit fallthroughs in switches
https://bugs.webkit.org/show_bug.cgi?id=127637
Summary
Add FALLTHROUGH and -Wimplicit-fallthrough to warn about unannotated implicit...
Joseph Pecoraro
Reported
2014-01-25 17:23:21 PST
clang has -Wimplicit-fallthrough and [[clang::fallthrough]]. Lets use them! <
http://clang.llvm.org/docs/LanguageExtensions.html#the-clang-fallthrough-attribute
> The clang::fallthrough attribute is used along with the -Wimplicit-fallthrough argument to annotate intentional fall-through between switch labels. It can only be applied to a null statement placed at a point of execution between any statement and the next switch label. It is common to mark these places with a specific comment, but this attribute is meant to replace comments with a more strict annotation, which can be checked by the compiler. This attribute doesn’t change semantics of the code and can be used wherever an intended fall-through occurs. It is designed to mimic control-flow statements like break;, so it can be placed in most places where break; can, but only if there are no statements on the execution path between it and the next switch label.
Attachments
[PATCH] Proposed Fix - FALLTHROUGH
(8.03 KB, patch)
2014-01-25 17:24 PST
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(9.07 KB, patch)
2014-01-25 17:29 PST
,
Joseph Pecoraro
darin
: review+
Details
Formatted Diff
Diff
[PATCH] For Landing
(9.72 KB, patch)
2014-01-25 19:16 PST
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Joseph Pecoraro
Comment 1
2014-01-25 17:24:10 PST
Created
attachment 222242
[details]
[PATCH] Proposed Fix - FALLTHROUGH Any reason not to add this? This adds it to WTF and enables for WTF. I haven't looked at other projects yet (JSC, WebCore, ...)
WebKit Commit Bot
Comment 2
2014-01-25 17:25:08 PST
Attachment 222242
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/Compiler.h:160: Extra space before [ [whitespace/braces] [5] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:234: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:234: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:235: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:236: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:256: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:256: More than one command on the same line in if [whitespace/parens] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:257: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:257: More than one command on the same line in if [whitespace/parens] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:288: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:288: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:289: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:290: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:291: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:292: More than one command on the same line [whitespace/newline] [4] Total errors found: 15 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Joseph Pecoraro
Comment 3
2014-01-25 17:29:04 PST
Created
attachment 222243
[details]
[PATCH] Proposed Fix Now with a ChangeLog.
WebKit Commit Bot
Comment 4
2014-01-25 17:29:51 PST
Attachment 222243
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/Compiler.h:160: Extra space before [ [whitespace/braces] [5] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:234: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:234: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:235: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:236: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:256: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:256: More than one command on the same line in if [whitespace/parens] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:257: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:257: More than one command on the same line in if [whitespace/parens] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:288: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:288: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:289: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:290: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:291: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:292: More than one command on the same line [whitespace/newline] [4] Total errors found: 15 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 5
2014-01-25 18:30:13 PST
Comment on
attachment 222243
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=222243&action=review
> Source/WTF/wtf/Compiler.h:159 > +#if !defined(FALLTHROUGH) && COMPILER_SUPPORTS(FALLTHROUGH_WARNINGS) > +#if COMPILER(CLANG)
Should just be a single #if with another && in it.
> Source/WTF/wtf/Compiler.h:165 > +#define FALLTHROUGH do { } while (false)
Can this just be defined to nothing? I wouldn’t think it needs to be a statement (see my comments below about semicolons).
> Source/WTF/wtf/dtoa/fast-dtoa.cc:257 > + FALLTHROUGH;
Does this really require a semicolon after it? That doesn’t seem quite right to me, but maybe that’s how the clang feature works? I don’t think we should keep the "// else fallthrough" comments since we are adding the FALLTHROUGH macros, which say the same thing.
Joseph Pecoraro
Comment 6
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.
Joseph Pecoraro
Comment 7
2014-01-25 19:16:34 PST
Created
attachment 222245
[details]
[PATCH] For Landing
WebKit Commit Bot
Comment 8
2014-01-25 19:18:15 PST
Attachment 222245
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/Compiler.h:159: Extra space before [ [whitespace/braces] [5] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:234: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:234: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:235: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:236: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:256: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:256: More than one command on the same line in if [whitespace/parens] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:257: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:257: More than one command on the same line in if [whitespace/parens] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:288: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:288: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:289: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:290: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:291: More than one command on the same line [whitespace/newline] [4] ERROR: Source/WTF/wtf/unicode/UTF8.cpp:292: More than one command on the same line [whitespace/newline] [4] Total errors found: 15 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 9
2014-01-25 19:50:25 PST
Comment on
attachment 222245
[details]
[PATCH] For Landing Clearing flags on attachment: 222245 Committed
r162793
: <
http://trac.webkit.org/changeset/162793
>
WebKit Commit Bot
Comment 10
2014-01-25 19:50:28 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug