mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Correct coding style on fall through (#12140)
parent
bff69e192b
commit
ad9080338c
|
@ -157,7 +157,7 @@ enum SomeEnumeration {
|
||||||
* Use curly braces and put the contained statements on their own lines (e.g., don't put them directly after the **if**).
|
* Use curly braces and put the contained statements on their own lines (e.g., don't put them directly after the **if**).
|
||||||
* Opening curly bracket **{** stays on the first line, closing curly bracket **}** gets a line to itself (except for the **}** preceding an **else**, which should be on the same line as the **else**).
|
* Opening curly bracket **{** stays on the first line, closing curly bracket **}** gets a line to itself (except for the **}** preceding an **else**, which should be on the same line as the **else**).
|
||||||
* When only a single statement is contained, the brackets can be omitted. In this case, put the single statement on the same line as the preceding keyword (**if**, **while**, etc.). Note that this is only allowed for if statements without an **else** clause.
|
* When only a single statement is contained, the brackets can be omitted. In this case, put the single statement on the same line as the preceding keyword (**if**, **while**, etc.). Note that this is only allowed for if statements without an **else** clause.
|
||||||
* All fall throughs must be documented, using a **FALLTHROUGH** define/macro.
|
* Non-trivial fall throughs must be documented, using a `[[fallthrough]]` attribute.
|
||||||
* The NOT_REACHED() macro can be used in default constructs that should never be reached.
|
* The NOT_REACHED() macro can be used in default constructs that should never be reached.
|
||||||
* Unconditional loops are written with **`for (;;) {`**
|
* Unconditional loops are written with **`for (;;) {`**
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ switch (a) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
DoSomething();
|
DoSomething();
|
||||||
FALLTHROUGH;
|
[[fallthrough]];
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
DoMore();
|
DoMore();
|
||||||
|
@ -191,7 +191,7 @@ switch (a) {
|
||||||
int r = 2;
|
int r = 2;
|
||||||
|
|
||||||
DoEvenMore(a);
|
DoEvenMore(a);
|
||||||
FALLTHROUGH;
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
|
|
||||||
case 4: {
|
case 4: {
|
||||||
|
|
Loading…
Reference in New Issue