From f04070940e838c1a21b1d96e34054e66f231e772 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sun, 22 Feb 2015 11:57:46 +0100 Subject: [PATCH] Fixed setVarId on ternary operator in initialization list --- lib/tokenize.cpp | 2 +- test/testvarid.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8b4dab269..57aa0e4e9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2491,7 +2491,7 @@ static void setVarIdClassDeclaration(Token * const startToken, setVarIdStructMembers(&tok, structMembers, _varId); } } - } else if (indentlevel == 0 && tok->str() == ":") + } else if (indentlevel == 0 && tok->str() == ":" && !initListEndToken) initListEndToken = findInitListEndToken(tok->previous()); } } diff --git a/test/testvarid.cpp b/test/testvarid.cpp index bd51dbedb..9b5dec29a 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1655,6 +1655,18 @@ private: "3: int x@2 ;\n" "4: } ;\n", tokenize(code6)); + + // #6520 + const char code7[] = "class A {\n" + " A(int x) : y(a?0:1), x(x) {}\n" + " int x, y;\n" + "};"; + ASSERT_EQUALS("\n\n##file 0\n" + "1: class A {\n" + "2: A ( int x@1 ) : y@3 ( a ? 0 : 1 ) , x@2 ( x@1 ) { }\n" + "3: int x@2 ; int y@3 ;\n" + "4: } ;\n", + tokenize(code7)); } void varid_operator() {