diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 3fd1ff9024e8..dffc309a09ef 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -615,7 +615,9 @@ void UnwrappedLineParser::parseRecord() { if (FormatTok.Tok.is(tok::l_paren)) { parseParens(); } - if (FormatTok.Tok.is(tok::identifier)) + // The actual identifier can be a nested name specifier. + while (FormatTok.Tok.is(tok::identifier) || + FormatTok.Tok.is(tok::coloncolon)) nextToken(); if (FormatTok.Tok.is(tok::colon)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1d3463ccfd24..3c929a3f532c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1519,13 +1519,17 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) { // Actual definitions... verifyFormat("struct {} n;"); - verifyFormat("template