From 8c5fba9f87f39ff18425747fcea2ac9f364e3cfe Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 16 Jan 2013 16:23:19 +0000 Subject: Fix parsing error in conditional expressions. We used to incorrectly parse aaaaaa ? aaaaaa(aaaaaa) : aaaaaaaa; Due to an l_paren being followed by a colon, we assumed it to be part of a constructor initializer. Thus, we never found the colon belonging to the conditional expression, marked the line as bing incorrect and did not format it. llvm-svn: 172621 --- clang/lib/Format/Format.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index ebf493c628a..22166aa27ab 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -886,6 +886,8 @@ public: break; case tok::colon: // Colons from ?: are handled in parseConditional(). + if (Tok->Parent->is(tok::r_paren)) + Tok->Type = TT_CtorInitializerColon; if (ColonIsObjCMethodExpr) Tok->Type = TT_ObjCMethodExpr; break; @@ -894,10 +896,7 @@ public: TT_ObjCMethodSpecifier; if (!parseParens()) return false; - if (CurrentToken != NULL && CurrentToken->is(tok::colon)) { - CurrentToken->Type = TT_CtorInitializerColon; - next(); - } else if (CurrentToken != NULL && ParensWereObjCReturnType) { + if (CurrentToken != NULL && ParensWereObjCReturnType) { CurrentToken->Type = TT_ObjCSelectorStart; next(); } -- cgit v1.2.3