diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 625ffa6fb..60dbeafd4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2548,7 +2548,7 @@ static const std::set notstart_c = make_container< std::set notstart_cpp = make_container< std::set > () << notstart_c - << "delete" << "friend" << "new" << "throw" << "using" << "virtual" << "explicit" << "const_cast" << "dynamic_cast" << "reinterpret_cast" << "static_cast" ; + << "delete" << "friend" << "new" << "throw" << "using" << "virtual" << "explicit" << "const_cast" << "dynamic_cast" << "reinterpret_cast" << "static_cast" << "template"; void Tokenizer::setVarIdPass1() { diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 0d375b339..d64a4b49b 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -134,6 +134,7 @@ private: TEST_CASE(varid_templateNamespaceFuncPtr); // #4172 TEST_CASE(varid_templateArray); TEST_CASE(varid_templateParameter); // #7046 set varid for "X": std::array Y; + TEST_CASE(varid_templateUsing); // #5781 #7273 TEST_CASE(varid_cppcast); // #6190 TEST_CASE(varid_variadicFunc); TEST_CASE(varid_typename); // #4644 @@ -2026,6 +2027,15 @@ private: tokenize(code)); } + void varid_templateUsing() { // #5781 #7273 + const char code[] = "template using X = Y;\n" + "X x;"; + + ASSERT_EQUALS("1: template < class T > using X ; X = Y < T > ;\n" // TODO: "1: \n" + "2: X < int > x@1 ;\n", // TODO: "2: Y x@1 ;" + tokenize(code)); + } + void varid_cppcast() { ASSERT_EQUALS("1: const_cast < int * > ( code ) [ 0 ] = 0 ;\n", tokenize("const_cast(code)[0] = 0;"));