diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 03e79a22954e80..2dda5d89a3ac64 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -423,7 +423,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { State.Stack.back().BreakBeforeParameter && Current.CanBreakBefore) return true; - if (State.Column <= NewLineColumn) + if (!State.Line->First->is(tok::kw_enum) && State.Column <= NewLineColumn) return false; if (Style.AlwaysBreakBeforeMultilineStrings && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index fe16eeaba53cd3..ece7c61a999c7b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1929,6 +1929,24 @@ TEST_F(FormatTest, FormatsEnum) { " TWO\n" "};\n" "int i;"); + + FormatStyle EightIndent = getLLVMStyle(); + EightIndent.IndentWidth = 8; + verifyFormat("enum {\n" + " VOID,\n" + " CHAR,\n" + " SHORT,\n" + " INT,\n" + " LONG,\n" + " SIGNED,\n" + " UNSIGNED,\n" + " BOOL,\n" + " FLOAT,\n" + " DOUBLE,\n" + " COMPLEX\n" + "};", + EightIndent); + // Not enums. verifyFormat("enum X f() {\n" " a();\n"