Changeset - r28794:13cc1ce7b773
[Not reviewed]
master
0 1 0
merni-ns - 2 months ago 2024-02-20 20:50:08
66267867+merni-ns@users.noreply.github.com
Codefix: Correct coding style on fall through (#12140)
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
CODINGSTYLE.md
Show inline comments
 
@@ -154,13 +154,13 @@ enum SomeEnumeration {
 

	
 
### Control flow
 
* Put a space before the parentheses in **if**, **switch**, **for** and **while** statements.
 
* 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**).
 
* 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.
 
* Unconditional loops are written with **`for (;;) {`**
 

	
 
```c++
 
if (a == b) {
 
	Foo();
 
@@ -177,24 +177,24 @@ if (a == b) Foo();
 

	
 
switch (a) {
 
	case 0: DoSomethingShort(); break;
 

	
 
	case 1:
 
		DoSomething();
 
		FALLTHROUGH;
 
		[[fallthrough]];
 

	
 
	case 2:
 
		DoMore();
 
		b = a;
 
		break;
 

	
 
	case 3: {
 
		int r = 2;
 

	
 
		DoEvenMore(a);
 
		FALLTHROUGH;
 
		[[fallthrough]];
 
	}
 

	
 
	case 4: {
 
		int q = 345;
 

	
 
		DoIt();
0 comments (0 inline, 0 general)