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 @@ -1881,7 +1881,7 @@ } } - if (FormatTok->is(Keywords.kw_interface)) { + if (!Style.isCpp() && FormatTok->is(Keywords.kw_interface)) { if (parseStructLike()) return; break; 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 @@ -25429,6 +25429,13 @@ verifyFormat("auto x = 5s .count() == 5;"); } +TEST_F(FormatTest, InterfaceAsClassMemberName) { + verifyFormat("class Foo {\n" + " int interface;\n" + " Foo::Foo(int iface) : interface{iface} {}\n" + "}"); +} + } // namespace } // namespace test } // namespace format