From b7dcdc00d013dbb5793d0553304da4f987269a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 1 Apr 2017 22:22:37 +0200 Subject: [PATCH] Fixed #7970 (ValueType: no types set below 'new std::string') --- lib/symboldatabase.cpp | 4 ++-- test/testsymboldatabase.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index d8f181312..9c0578625 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5037,7 +5037,7 @@ void SymbolDatabase::setValueTypeInTokenList() typeTok = typeTok->tokAt(2); } if (!Token::Match(typeTok, "%type% ;|[|(")) - return; + continue; typestr += typeTok->str(); ValueType vt; vt.pointer = 1; @@ -5049,7 +5049,7 @@ void SymbolDatabase::setValueTypeInTokenList() if (vt.type == ValueType::Type::UNKNOWN_TYPE) vt.fromLibraryType(typestr, _settings); if (vt.type == ValueType::Type::UNKNOWN_TYPE) - return; + continue; if (typeTok->isUnsigned()) vt.sign = ValueType::Sign::UNSIGNED; else if (typeTok->isSigned()) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index c5bfaa35b..502765146 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -4439,6 +4439,7 @@ private: ASSERT_EQUALS("signed int", typeOf("; auto x = 3;", "x")); ASSERT_EQUALS("signed int *", typeOf("; auto *p = (int *)0;", "p")); ASSERT_EQUALS("signed int *", typeOf("; auto data = new int[100];", "data")); + ASSERT_EQUALS("signed int", typeOf("; auto data = new std::string; int x=1000; x=x/5;", "/")); // #7970 ASSERT_EQUALS("signed int *", typeOf("; auto data = new (nothrow) int[100];", "data")); ASSERT_EQUALS("signed int *", typeOf("; auto data = new (std::nothrow) int[100];", "data")); ASSERT_EQUALS("const signed short", typeOf("short values[10]; void f() { for (const auto *x : values); }", "x"));