From 58e28cb00eea70f1634afce4a166101c88b901ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 5 Jan 2016 19:47:11 +0100 Subject: [PATCH] ValueType: Better handling of unsigned unknown types --- lib/symboldatabase.cpp | 2 ++ test/testsymboldatabase.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a5fa2a6ed..2bbdc8e05 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3770,6 +3770,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V valuetype->type = type->isLong() ? ValueType::Type::LONGDOUBLE : ValueType::Type::DOUBLE; else if (type->str() == "struct") valuetype->type = ValueType::Type::NONSTD; + else if (type->isName() && valuetype->sign != ValueType::Sign::UNKNOWN_SIGN && valuetype->pointer == 0U) + return nullptr; else if (type->str() == "*") valuetype->pointer++; if (!type->originalName().empty()) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 6e6e02797..c1ae75e9c 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3084,7 +3084,7 @@ private: std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); const Token * const tok = Token::findsimplematch(tokenizer.tokens(),str); - return tok->valueType()->str(); + return tok->valueType() ? tok->valueType()->str() : std::string(); } void valuetype() { @@ -3167,6 +3167,7 @@ private: ASSERT_EQUALS("long long", typeOf("a = (long long)32;", "(")); ASSERT_EQUALS("long double", typeOf("a = (long double)32;", "(")); ASSERT_EQUALS("char", typeOf("a = static_cast(32);", "(")); + ASSERT_EQUALS("", typeOf("a = (unsigned x)0;", "(")); // const.. ASSERT_EQUALS("const char *", typeOf("a = \"123\";", "\"123\""));