From 957e0790c6f501e79fc757380836f82163c26b57 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Wed, 1 May 2013 18:50:35 +0200 Subject: [PATCH] Tokenizer::setVarId: assert that strange code with same type names and variable names work. Ticket: #3990 --- test/testtokenize.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index aef1476d3..6f604fb32 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -290,6 +290,7 @@ private: TEST_CASE(varidclass13); TEST_CASE(varidclass14); TEST_CASE(varidclass15); // initializer list + TEST_CASE(varid_classnameshaddowsvariablename) // #3990 TEST_CASE(file1); TEST_CASE(file2); @@ -4717,6 +4718,22 @@ private: ASSERT_EQUALS(expected, tokenizeDebugListing(code)); } + void varid_classnameshaddowsvariablename() { + const char code[] = "class Data;\n" + "void strange_declarated(const Data& Data);\n" + "void handleData(const Data& data) {\n" + " strange_declarated(data);\n" + "}\n"; + const char expected[] = "\n\n##file 0\n" + "1: class Data ;\n" + "2: void strange_declarated ( const Data & Data@1 ) ;\n" + "3: void handleData ( const Data & data@2 ) {\n" + "4: strange_declarated ( data@2 ) ;\n" + "5: }\n"; + ASSERT_EQUALS(expected, tokenizeDebugListing(code)); + + } + void file1() { const char code[] = "a1\n" "#file \"b\"\n"