Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Documentation/process: Add fallthrough pseudo-keyword

Describe the fallthrough pseudo-keyword.

Convert the coding-style.rst example to the keyword style.
Add description and links to deprecated.rst.

Miguel Ojeda comments on the eventual [[fallthrough]] syntax:
"Note that C17/C18 does not have [[fallthrough]].

C++17 introduced it, as it is mentioned above. I would keep the
__attribute__((fallthrough)) -> [[fallthrough]] change you did,
though, since that is indeed the standard syntax (given the paragraph
references C++17).

I was told by Aaron Ballman (who is proposing them for C) that it is
more or less likely that it becomes standardized in C2x. However, it
is still not added to the draft (other attributes are already,
though). See N2268 and N2269:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2268.pdf (fallthrough)
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2269.pdf (attributes in general)"

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joe Perches and committed by
Linus Torvalds
b9918bdc 294f69e6

+24 -11
+1 -1
Documentation/process/coding-style.rst
··· 56 56 case 'K': 57 57 case 'k': 58 58 mem <<= 10; 59 - /* fall through */ 59 + fallthrough; 60 60 default: 61 61 break; 62 62 }
+23 -10
Documentation/process/deprecated.rst
··· 122 122 123 123 Implicit switch case fall-through 124 124 --------------------------------- 125 - The C language allows switch cases to "fall through" when 126 - a "break" statement is missing at the end of a case. This, 127 - however, introduces ambiguity in the code, as it's not always 128 - clear if the missing break is intentional or a bug. As there 129 - have been a long list of flaws `due to missing "break" statements 125 + The C language allows switch cases to "fall-through" when a "break" statement 126 + is missing at the end of a case. This, however, introduces ambiguity in the 127 + code, as it's not always clear if the missing break is intentional or a bug. 128 + 129 + As there have been a long list of flaws `due to missing "break" statements 130 130 <https://cwe.mitre.org/data/definitions/484.html>`_, we no longer allow 131 - "implicit fall-through". In order to identify an intentional fall-through 132 - case, we have adopted the marking used by static analyzers: a comment 133 - saying `/* Fall through */`. Once the C++17 `__attribute__((fallthrough))` 134 - is more widely handled by C compilers, static analyzers, and IDEs, we can 135 - switch to using that instead. 131 + "implicit fall-through". 132 + 133 + In order to identify intentional fall-through cases, we have adopted a 134 + pseudo-keyword macro 'fallthrough' which expands to gcc's extension 135 + __attribute__((__fallthrough__)). `Statement Attributes 136 + <https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html>`_ 137 + 138 + When the C17/C18 [[fallthrough]] syntax is more commonly supported by 139 + C compilers, static analyzers, and IDEs, we can switch to using that syntax 140 + for the macro pseudo-keyword. 141 + 142 + All switch/case blocks must end in one of: 143 + 144 + break; 145 + fallthrough; 146 + continue; 147 + goto <label>; 148 + return [expression];