Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2995,7 +2995,6 @@ void UnwrappedLineParser::parseRequiresClause(FormatToken *RequiresToken) { assert(FormatTok->getPreviousNonComment() == RequiresToken); assert(RequiresToken->is(tok::kw_requires) && "'requires' expected"); - assert(RequiresToken->getType() == TT_Unknown); // If there is no previous token, we are within a requires expression, // otherwise we will always have the template or function declaration in front @@ -3024,7 +3023,6 @@ void UnwrappedLineParser::parseRequiresExpression(FormatToken *RequiresToken) { assert(FormatTok->getPreviousNonComment() == RequiresToken); assert(RequiresToken->is(tok::kw_requires) && "'requires' expected"); - assert(RequiresToken->getType() == TT_Unknown); RequiresToken->setFinalizedType(TT_RequiresExpression); Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -23808,6 +23808,15 @@ verifyFormat("template \n" "concept C = [] && requires(T t) { typename T::size_type; };"); + + verifyFormat("template \n" + "concept C =\n" + "#if X\n" + " A &&\n" + "#else\n" + " B &&\n" + "#endif\n" + " requires C2;"); } TEST_F(FormatTest, RequiresClausesPositions) {