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 @@ -1439,7 +1439,7 @@ return; case tok::kw_requires: parseRequires(); - break; + return; case tok::kw_enum: // Ignore if this is part of "template is(tok::less)) { 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 @@ -3556,6 +3556,11 @@ "struct b_struct {};\n" "} // namespace B\n", Style); + verifyFormat("template constexpr void foo requires(I == 42) {}\n" + "namespace ns {\n" + "void foo() {}\n" + "} // namespace ns\n", + Style); } TEST_F(FormatTest, NamespaceMacros) {