diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2874,6 +2874,8 @@ if (!tryToParseBracedList()) break; } + if (FormatTok->is(tok::l_square) && !tryToParseLambda()) + break; if (FormatTok->Tok.is(tok::semi)) return; if (Style.isCSharp() && FormatTok->is(Keywords.kw_where)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -23212,6 +23212,15 @@ Style); } +TEST_F(FormatTest, ShortTemplatedArgumentLists) { + auto Style = getLLVMStyle(); + + verifyFormat("struct Y : X<[] { return 0; }> {};", Style); + verifyFormat("struct Y<[] { return 0; }> {};", Style); + + verifyFormat("struct Z : X {};", Style); +} + } // namespace } // namespace format } // namespace clang