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 @@ -1562,9 +1562,13 @@ parseConcept(); return; case tok::kw_requires: { - bool ParsedClause = parseRequires(); - if (ParsedClause) - return; + if (Style.isCpp()) { + bool ParsedClause = parseRequires(); + if (ParsedClause) + return; + } else { + nextToken(); + } break; } case tok::kw_enum: diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -323,6 +323,7 @@ verifyFormat("var struct = 2;"); verifyFormat("var union = 2;"); verifyFormat("var interface = 2;"); + verifyFormat("var requires = {};"); verifyFormat("interface = 2;"); verifyFormat("x = interface instanceof y;"); verifyFormat("interface Test {\n"