@@ -102,6 +102,7 @@ class TestVarID : public TestFixture {
102102 TEST_CASE (varid68); // #11740 - switch (str_chars(&strOut)[0])
103103 TEST_CASE (varid69);
104104 TEST_CASE (varid70); // #12660 - function
105+ TEST_CASE (varid71); // #12676 - wrong varid in uninstantiated templated constructor
105106 TEST_CASE (varid_for_1);
106107 TEST_CASE (varid_for_2);
107108 TEST_CASE (varid_cpp_keywords_in_c_code);
@@ -1294,6 +1295,72 @@ class TestVarID : public TestFixture {
12941295 ASSERT_EQUALS (expected3, tokenize (code3, true ));
12951296 }
12961297
1298+ void varid71 () {
1299+ const char code[] = " namespace myspace {\n "
1300+ " \n "
1301+ " template <typename T>\n "
1302+ " class CounterTest {\n "
1303+ " public:\n "
1304+ " CounterTest(T _obj);\n "
1305+ " template <typename T2>\n "
1306+ " CounterTest(const CounterTest<T2>& ptr);\n "
1307+ " T obj;\n "
1308+ " int count;\n "
1309+ " };\n "
1310+ " \n "
1311+ " template <typename T>\n "
1312+ " CounterTest<T>::CounterTest(T _obj) : obj(_obj) {\n "
1313+ " count = 0;\n "
1314+ " }\n "
1315+ " \n "
1316+ " template <typename T>\n "
1317+ " template <typename T2>\n "
1318+ " CounterTest<T>::CounterTest(const CounterTest<T2>& p) : obj(0) {\n "
1319+ " count = p.count;\n "
1320+ " }\n "
1321+ " \n "
1322+ " }\n "
1323+ " \n "
1324+ " using namespace myspace;\n "
1325+ " CounterTest<int> myobj(0);\n " ;
1326+ const char expected[] = " 1: namespace myspace {\n "
1327+ " 2:\n "
1328+ " 3: class CounterTest<int> ;\n "
1329+ " 4:\n "
1330+ " |\n "
1331+ " 17:\n "
1332+ " 18: template < typename T >\n "
1333+ " 19: template < typename T2 >\n "
1334+ " 20: CounterTest < T > :: CounterTest ( const CounterTest < T2 > & p@1 ) : obj ( 0 ) {\n "
1335+ " 21: count = p@1 . count@2 ;\n "
1336+ " 22: }\n "
1337+ " 23:\n "
1338+ " 24: }\n "
1339+ " 25:\n "
1340+ " 26: using namespace myspace ;\n "
1341+ " 27: myspace :: CounterTest<int> myobj@3 ( 0 ) ;\n "
1342+ " 4: class myspace :: CounterTest<int> {\n "
1343+ " 5: public:\n "
1344+ " 6: CounterTest<int> ( int _obj@4 ) ;\n "
1345+ " 7: template < typename T2 >\n "
1346+ " 8: CounterTest<int> ( const myspace :: CounterTest < T2 > & ptr@5 ) ;\n "
1347+ " 9: int obj@6 ;\n "
1348+ " 10: int count@7 ;\n "
1349+ " 11: } ;\n "
1350+ " 12:\n "
1351+ " 13:\n "
1352+ " 14: myspace :: CounterTest<int> :: CounterTest<int> ( int _obj@8 ) : obj@6 ( _obj@8 ) {\n "
1353+ " 15: count@7 = 0 ;\n "
1354+ " 16: }\n "
1355+ " 17:\n "
1356+ " 18:\n "
1357+ " 19:\n "
1358+ " 20: myspace :: CounterTest<int> :: CounterTest<int> ( const myspace :: CounterTest < T2 > & p@9 ) : obj@6 ( 0 ) {\n "
1359+ " 21: count@7 = p@9 . count@10 ;\n "
1360+ " 22: }\n " ;
1361+ ASSERT_EQUALS (expected, tokenize (code, true ));
1362+ }
1363+
12971364 void varid_for_1 () {
12981365 const char code[] = " void foo(int a, int b) {\n "
12991366 " for (int a=1,b=2;;) {}\n "
0 commit comments