diff --git a/Makefile b/Makefile index 0935454f5..5d53dfe38 100644 --- a/Makefile +++ b/Makefile @@ -730,7 +730,7 @@ test/testsuite.o: test/testsuite.cpp lib/config.h lib/errorlogger.h lib/errortyp test/testsuppressions.o: test/testsuppressions.cpp cli/threadexecutor.h lib/analyzerinfo.h lib/check.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h test/testsuite.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testsuppressions.o test/testsuppressions.cpp -test/testsymboldatabase.o: test/testsymboldatabase.cpp lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h test/testutils.h +test/testsymboldatabase.o: test/testsymboldatabase.cpp externals/tinyxml/tinyxml2.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h test/testutils.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testsymboldatabase.o test/testsymboldatabase.cpp test/testthreadexecutor.o: test/testthreadexecutor.cpp cli/threadexecutor.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h test/testsuite.h diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 30ccc04e6..98f9fad21 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6148,6 +6148,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to TokenList tokenList(mSettings); std::istringstream istr(typestr+";"); tokenList.createTokens(istr); + tokenList.simplifyStdType(); if (parsedecl(tokenList.front(), &valuetype, mDefaultSignedness, mSettings)) { valuetype.originalTypeName = typestr; setValueType(tok, valuetype); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 803d9be97..ac0054d2e 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include struct InternalError; @@ -6931,6 +6932,35 @@ private: ASSERT_EQUALS("signed long long", typeOf("enum E : long long { }; void foo() { E e[3]; bar(e[0]); }", "[ 0")); ASSERT_EQUALS("unsigned long long", typeOf("enum E : unsigned long long { }; void foo() { E e[3]; bar(e[0]); }", "[ 0")); +#define CHECK_LIBRARY_FUNCTION_RETURN_TYPE(type) do { \ + Settings sF; \ + const char xmldata[] = "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + ""; \ + tinyxml2::XMLDocument doc; \ + doc.Parse(xmldata, sizeof(xmldata)); \ + sF.library.load(doc); \ + ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", "test.cpp", &sF)); \ + } while (false) + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(bool); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(signed char); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(unsigned char); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(signed short); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(unsigned short); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(signed int); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(unsigned int); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(signed long); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(unsigned long); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(signed long long); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(unsigned long long); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(void *); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(void * *); + CHECK_LIBRARY_FUNCTION_RETURN_TYPE(const void *); +#undef CHECK_LIBRARY_FUNCTION_RETURN_TYPE + // Library types { // Char types