Closed
Bug 1215411
(MOZ_FALLTHROUGH)
Opened 9 years ago
Closed 9 years ago
Define MOZ_FALLTHROUGH annotation to suppress clang's -Wimplicit-fallthrough warnings
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla44
Tracking | Status | |
---|---|---|
firefox44 | --- | fixed |
People
(Reporter: cpeterson, Assigned: cpeterson)
References
Details
Attachments
(1 file)
1.94 KB,
patch
|
botond
:
review+
Ms2ger
:
feedback+
|
Details | Diff | Splinter Review |
clang's optional -Wimplicit-fallthrough compiler warning warns about switch
cases that fall through without a break or return statement. MOZ_FALLTHROUGH is an annotation to suppress these warnings. MOZ_FALLTHROUGH is only needed on cases that have code.
I'd like to start fixing the 670 -Wimplicit-fallthrough warnings in mozilla-central. I have local patches to annotate about 200 cases so far and I have found at least 4 real bugs. :)
switch (foo) {
case 1: // These cases have no code. No fallthrough annotations are needed.
case 2:
case 3:
foo = 4; // This case has code, so a fallthrough annotation is needed:
MOZ_FALLTHROUGH;
default:
return foo;
}
clang's fallthrough annotation is only available starting in C++11 because it uses C++11 annotation syntax. MSVC's __fallthrough annotations are checked by MSVC /analyze (Code Analysis), though I have not tested it. gcc does not have a similar warning or annotation.
Attachment #8674690 -
Flags: review?(Ms2ger)
Comment 1•9 years ago
|
||
Comment on attachment 8674690 [details] [diff] [review]
MOZ_FALLTHROUGH.patch
Review of attachment 8674690 [details] [diff] [review]:
-----------------------------------------------------------------
Seems neat.
Attachment #8674690 -
Flags: review?(botond)
Attachment #8674690 -
Flags: review?(Ms2ger)
Attachment #8674690 -
Flags: feedback+
Updated•9 years ago
|
Attachment #8674690 -
Flags: review?(botond) → review-
Comment 2•9 years ago
|
||
Comment on attachment 8674690 [details] [diff] [review]
MOZ_FALLTHROUGH.patch
Sorry, I meant to r+!
Attachment #8674690 -
Flags: review- → review+
Assignee | ||
Updated•9 years ago
|
Alias: MOZ_FALLTHROUGH
Keywords: checkin-needed
Comment 5•9 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox44:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Assignee | ||
Updated•9 years ago
|
Depends on: MOZ_FALLTHROUGH_ASSERT
Assignee | ||
Updated•5 years ago
|
Depends on: fallthrough
You need to log in
before you can comment on or make changes to this bug.
Description
•