Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -2306,10 +2306,13 @@ if (PrevToken->Tok.isLiteral() || PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true, - tok::kw_false, tok::r_brace)) { + tok::kw_false)) { return TT_BinaryOperator; } + if (PrevToken->is(tok::r_brace) && Tok.isOneOf(tok::amp, tok::ampamp)) + return TT_BinaryOperator; + const FormatToken *NextNonParen = NextToken; while (NextNonParen && NextNonParen->is(tok::l_paren)) NextNonParen = NextNonParen->getNextNonComment(); Index: clang/unittests/Format/TokenAnnotatorTest.cpp =================================================================== --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -85,6 +85,12 @@ Tokens = annotate("case &x:"); EXPECT_EQ(Tokens.size(), 5u) << Tokens; EXPECT_TOKEN(Tokens[1], tok::amp, TT_UnaryOperator); + + Tokens = annotate("struct {\n" + " int foo;\n" + "} *ptr;\n"); + EXPECT_EQ(Tokens.size(), 10u) << Tokens; + EXPECT_TOKEN(Tokens[6], tok::star, TT_PointerOrReference); } TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {