diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 3df17141f24..e525bdd7609 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -446,7 +446,7 @@ static Token* skipDecl(Token* tok, std::vector* inner = nullptr) if (!Token::Match(tok->previous(), "( %name%")) return tok; Token *vartok = tok; - while (Token::Match(vartok, "%name%|*|&|::|<")) { + while (Token::Match(vartok, "%name%|*|&|&&|::|<")) { if (vartok->str() == "<") { if (vartok->link()) vartok = vartok->link(); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 8348e0cd44b..6efda65c11b 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -587,6 +587,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(valueType3); TEST_CASE(valueTypeThis); TEST_CASE(valueTypeChar); + TEST_CASE(valueTypeRValueReference); TEST_CASE(variadic1); // #7453 TEST_CASE(variadic2); // #7649 @@ -10175,6 +10176,10 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS("char", typeOf("char buf[10]; buf[0] = 'x';", "[ 0 ]", true, &s)); } + void valueTypeRValueReference() { + TODO_ASSERT_EQUALS("", "bool", typeOf("void f(std::string&& s = {})", "&&")); + } + void variadic1() { // #7453 { GET_SYMBOL_DB("CBase* create(const char *c1, ...);\n" diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index d8a5b533bf3..ff5d18b3175 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -5277,6 +5277,12 @@ class TestValueFlow : public TestFixture { " continuous_src_time(std::complex f, double st = 0.0, double et = infinity) {}\n" "};"; (void)testValueOfX(code, 2U, 2); // Don't crash (#6494) + + code = "struct S {\n" // #14693 + " int i;\n" + " explicit S(std::string&& s = {}) : i(0) {}\n" + "};"; + ASSERT_EQUALS(false, testKnownValueOfTok(code, "{ } )", 0)); } bool isNotKnownValues(const char code[], const char str[]) {