diff --git a/src/cppcheck.cpp b/src/cppcheck.cpp index b3a9dbe28..33184e5c1 100644 --- a/src/cppcheck.cpp +++ b/src/cppcheck.cpp @@ -296,7 +296,7 @@ unsigned int CppCheck::check() fxml << ""; } - unsigned int result = _errorList.size(); + unsigned int result = static_cast(_errorList.size()); _errorList.clear(); return result; } diff --git a/src/tokenize.cpp b/src/tokenize.cpp index e5585d191..ed9049a82 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -290,7 +290,7 @@ void Tokenizer::tokenize(std::istream &code, const char FileName[]) { // The "_files" vector remembers what files have been tokenized.. _files.push_back(FileLister::simplifyPath(line.c_str())); - FileIndex = _files.size() - 1; + FileIndex = static_cast(_files.size() - 1); } lineNumbers.push_back(lineno); diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index f019ecae3..d83ddf03a 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -178,7 +178,7 @@ private: // Compare results.. ASSERT_EQUALS(expected[""], actual[""]); ASSERT_EQUALS(expected["__cplusplus"], actual["__cplusplus"]); - ASSERT_EQUALS(2, actual.size()); + ASSERT_EQUALS(2, static_cast(actual.size())); } @@ -199,7 +199,7 @@ private: // Compare results.. ASSERT_EQUALS("\n\n\nqwerty\n\n", actual[""]); ASSERT_EQUALS("\nabcdef\n\n\n\n", actual["WIN32"]); - ASSERT_EQUALS(2, actual.size()); + ASSERT_EQUALS(2, static_cast(actual.size())); } void test2() @@ -219,7 +219,7 @@ private: // Compare results.. ASSERT_EQUALS("\n\" # ifdef WIN32\"\n\n\n\n", actual[""]); ASSERT_EQUALS("\n\n\nqwerty\n\n", actual["WIN32"]); - ASSERT_EQUALS(2, actual.size()); + ASSERT_EQUALS(2, static_cast(actual.size())); } void test3() @@ -242,7 +242,7 @@ private: ASSERT_EQUALS("\n\n\n\n\n\n\n", actual[""]); ASSERT_EQUALS("\na\n\n\n\nc\n\n", actual["ABC"]); ASSERT_EQUALS("\na\n\nb\n\nc\n\n", actual["ABC;DEF"]); - ASSERT_EQUALS(3, actual.size()); + ASSERT_EQUALS(3, static_cast(actual.size())); } void test4() @@ -263,7 +263,7 @@ private: // Compare results.. ASSERT_EQUALS("\n\n\n\n\n\n", actual[""]); ASSERT_EQUALS("\nA\n\n\nA\n\n", actual["ABC"]); - ASSERT_EQUALS(2, actual.size()); + ASSERT_EQUALS(2, static_cast(actual.size())); } void test5() @@ -287,7 +287,7 @@ private: ASSERT_EQUALS("\n\n\nB\n\n\n\n\n", actual[""]); ASSERT_EQUALS("\nA\n\n\n\n\n\n\n", actual["ABC"]); ASSERT_EQUALS("\n\n\nB\n\nC\n\n\n", actual["DEF"]); - ASSERT_EQUALS(3, actual.size()); + ASSERT_EQUALS(3, static_cast(actual.size())); } void test6() @@ -321,7 +321,7 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Expected configurations: "" and "ABC" - ASSERT_EQUALS(2, actual.size()); + ASSERT_EQUALS(2, static_cast(actual.size())); } @@ -352,7 +352,7 @@ private: // Compare results.. ASSERT_EQUALS("\n\n\n\n", actual[""]); - ASSERT_EQUALS(1, actual.size()); + ASSERT_EQUALS(1, static_cast(actual.size())); } @@ -372,7 +372,7 @@ private: // Compare results.. ASSERT_EQUALS("\n\n\n\n", actual[""]); - ASSERT_EQUALS(1, actual.size()); + ASSERT_EQUALS(1, static_cast(actual.size())); } void if1() @@ -389,7 +389,7 @@ private: // Compare results.. ASSERT_EQUALS("\nABC\n\n", actual[""]); - ASSERT_EQUALS(1, actual.size()); + ASSERT_EQUALS(1, static_cast(actual.size())); } @@ -411,7 +411,7 @@ private: ASSERT_EQUALS("\n\n\n\n\n", actual[""]); ASSERT_EQUALS("\nABC\n\n\n\n", actual["DEF1"]); ASSERT_EQUALS("\n\n\nDEF\n\n", actual["DEF2"]); - ASSERT_EQUALS(3, actual.size()); + ASSERT_EQUALS(3, static_cast(actual.size())); } @@ -434,7 +434,7 @@ private: // Compare results.. ASSERT_EQUALS("\n\n\nB\n\n", actual[""]); ASSERT_EQUALS("\nA\n\n\n\n", actual["LIBVER>100"]); - ASSERT_EQUALS(2, actual.size()); + ASSERT_EQUALS(2, static_cast(actual.size())); } @@ -573,7 +573,7 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Compare results.. - ASSERT_EQUALS(1, actual.size()); + ASSERT_EQUALS(1, static_cast(actual.size())); ASSERT_EQUALS("int main(){ const char *a = \"#define A\n\";}\n", actual[""]); } @@ -641,7 +641,7 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Compare results.. - ASSERT_EQUALS(1, actual.size()); + ASSERT_EQUALS(1, static_cast(actual.size())); ASSERT_EQUALS("int main()\n{\nconst char *a = \"#include \n\";\nreturn 0;\n}\n", actual[""]); } @@ -690,7 +690,7 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Compare results.. - ASSERT_EQUALS(1, actual.size()); + ASSERT_EQUALS(1, static_cast(actual.size())); ASSERT_EQUALS("\nint main()\n{\nif( 'ABCD' == 0 );\nreturn 0;\n}\n", actual[""]); }