Skip to content

Commit 76fe008

Browse files
committed
Fix indentation after goto case/goto default
1 parent f3f22bb commit 76fe008

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/cppconv/dwriter/treecode.d

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,13 @@ void parseTreeToDCode(T)(ref CodeWriter code, DWriterData data, T tree, immutabl
923923

924924
if (!labelNeedsGoto.isFalse)
925925
{
926+
string lastLineIndent;
927+
getLastLineIndent(code, lastLineIndent);
928+
926929
if (tree.childs[1].content == "case")
927-
code.writeln("goto case;");
930+
code.write("goto case;\n", lastLineIndent);
928931
else if (tree.childs[1].content == "default")
929-
code.writeln("goto default;");
932+
code.write("goto default;\n", lastLineIndent);
930933
}
931934

932935
if (!tree.childs[1].content.among("case", "default"))

tests/single/test137.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ void f(int level)
3232
{
3333
}
3434
goto case;
35-
case 3:
35+
case 3:
3636
g();
3737
/+ __attribute__((fallthrough)); +/
3838
goto case;
39-
case 2:
39+
case 2:
4040
g();
4141
static if ((defined!"DEF" || (configValue!"__has_cpp_attribute_clang_fallthrough" && defined!"__has_cpp_attribute_clang_fallthrough") || (configValue!"__has_cpp_attribute_fallthrough" && defined!"__has_cpp_attribute_fallthrough")))
4242
{
@@ -46,11 +46,11 @@ case 2:
4646
{
4747
}
4848
goto case;
49-
case 5:
49+
case 5:
5050
g();
5151
/+ [[fallthrough]]; +/
5252
goto default;
53-
default:
53+
default:
5454
g();
5555
}
5656
}

tests/single/test97.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ int f(int i)
1111
case 1:
1212
r *= 3;
1313
goto case;
14-
case 2:
14+
case 2:
1515
r *= 4;
1616
goto case;
17-
case 3:
17+
case 3:
1818
r *= 5;
1919
goto default;
20-
default:
20+
default:
2121
r *= 6;
2222
}
2323
return r;

0 commit comments

Comments
 (0)