diff --git a/lib/token.cpp b/lib/token.cpp index 31ef9cad2..3a0e4987b 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2278,6 +2278,11 @@ std::pair Token::typeDecl(const Token * tok) if (vt && vt->containerTypeToken) return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) }; } + if (astIsSmartPointer(var->nameToken())) { + const ValueType* vt = var->valueType(); + if (vt && vt->smartPointerTypeToken) + return { vt->smartPointerTypeToken, vt->smartPointerTypeToken->linkAt(-1) }; + } } return {var->typeStartToken(), var->typeEndToken()->next()}; } else if (Token::simpleMatch(tok, "return")) { diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 5ba700e26..c39663371 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1916,6 +1916,12 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + check("void f() {\n" + " auto p = std::make_shared>();\n" + " p->push_back(1);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + settings.severity = severity_old; settings.checkLibrary = false; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1cf64dc31..6b57caaf7 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6758,6 +6758,8 @@ private: "void h() { " " [func=foo]{func();}(); " "}")); + ASSERT_NO_THROW(tokenizeAndStringify("template constexpr int n = 1;\n" + "template T a[n];\n")); // op op