From 5b0551054a1e8ddc1d939b197cb0e171f1187ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 22 May 2012 18:58:13 +0200 Subject: [PATCH] varid: better templates handling --- lib/tokenize.cpp | 4 ++++ test/testtokenize.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7f8d1fecd..065da30c2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2516,6 +2516,10 @@ static void setVarIdStructMembers(Token **tok1, if (struct_varid == 0) continue; + // Don't set varid for template function + if (TemplateSimplifier::templateParameters(tok->next()) > 0) + break; + std::map >::iterator structIterator; structIterator = structMembers->find(struct_varid); if (structIterator == structMembers->end()) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f2f1d2ab7..5930eee3c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -216,6 +216,7 @@ private: TEST_CASE(varid48); // #3785 - return (a*b) TEST_CASE(varid49); // #3799 - void f(std::vector) TEST_CASE(varid50); // #3760 - explicit + TEST_CASE(varid51); // don't set varid for template function TEST_CASE(varid_cpp_keywords_in_c_code); TEST_CASE(varidFunctionCall1); TEST_CASE(varidFunctionCall2); @@ -3267,6 +3268,13 @@ private: tokenizeDebugListing(code, false, "test.cpp")); } + void varid51() { // don't set varid on template function + const std::string code("T t; t.x<0>();"); + ASSERT_EQUALS("\n\n##file 0\n" + "1: T t@1 ; t@1 . x < 0 > ( ) ;\n", + tokenizeDebugListing(code, false, "test.cpp")); + } + void varid_cpp_keywords_in_c_code() { const char code[] = "void f() {\n" " delete d;\n"