summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 1d5904b3186..2d1c1e3f4ac 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -122,7 +122,9 @@ private:
if (CurrentToken->is(tok::r_paren)) {
if (MightBeFunctionType && CurrentToken->Next &&
- CurrentToken->Next->isOneOf(tok::l_paren, tok::l_square))
+ (CurrentToken->Next->is(tok::l_paren) ||
+ (CurrentToken->Next->is(tok::l_square) &&
+ !Contexts.back().IsExpression)))
Left->Type = TT_FunctionTypeLParen;
Left->MatchingParen = CurrentToken;
CurrentToken->MatchingParen = Left;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c8827c8dec6..747a140846b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3628,6 +3628,8 @@ TEST_F(FormatTest, FormatsFunctionTypes) {
// Other constructs can look somewhat like function types:
verifyFormat("A<sizeof(*x)> a;");
verifyFormat("#define DEREF_AND_CALL_F(x) f(*x)");
+ verifyFormat("some_var = function(*some_pointer_var)[0];");
+ verifyFormat("void f() { function(*some_pointer_var)[0] = 10; }");
}
TEST_F(FormatTest, BreaksLongDeclarations) {
OpenPOWER on IntegriCloud