diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 5df4a63ac..7d836b3dc 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -160,10 +160,6 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin preprocessor.preprocess(fin, filedata, configurations, filename, _settings._includePaths); } - // Unhandled chars found during preprocessing => abort checking this file - if (preprocessor.foundUnhandledChars()) - return 0; - if (_settings.checkConfiguration) { return 0; } diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 62b91421a..9627d96a7 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -38,7 +38,7 @@ bool Preprocessor::missingSystemIncludeFlag; char Preprocessor::macroChar = char(1); -Preprocessor::Preprocessor(Settings *settings, ErrorLogger *errorLogger) : _settings(settings), _errorLogger(errorLogger), _foundUnhandledChars(false) +Preprocessor::Preprocessor(Settings *settings, ErrorLogger *errorLogger) : _settings(settings), _errorLogger(errorLogger) { } @@ -482,11 +482,12 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri unsigned char ch = static_cast(str[i]); if (ch & 0x80) { std::ostringstream errmsg; - errmsg << "The code contains characters that are unhandled. " - << "Neither unicode nor extended ASCII are supported. " - << "(line=" << lineno << ", character code=" << std::hex << (int(ch) & 0xff) << ")"; - writeError(filename, lineno, _errorLogger, "syntaxError", errmsg.str()); - _foundUnhandledChars = true; + errmsg << "(character code = 0x" << std::hex << (int(ch) & 0xff) << ")"; + std::string info = errmsg.str(); + errmsg.str(""); + errmsg << "The code contains unhandled characters " << info << ". Checking continues, but do not expect valid results.\n" + << "The code contains characters that are unhandled " << info << ". Neither unicode nor extended ASCII are supported. Checking continues, but do not expect valid results."; + writeError(filename, lineno, _errorLogger, "unhandledCharacters", errmsg.str()); } if (_settings && _settings->terminated()) diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 411efbb34..472f7c229 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -251,10 +251,6 @@ public: file0 = f; } - bool foundUnhandledChars() const { - return _foundUnhandledChars; - } - private: void missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType); @@ -278,11 +274,6 @@ private: /** filename for cpp/c file - useful when reporting errors */ std::string file0; - - /** set to true if unhandled chars are found in code. any char is ok - * in comments and string literals, but variable/type names must - * have plain ascii characters. */ - bool _foundUnhandledChars; }; /// @} diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index e9de9f676..380d3f5d6 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -296,9 +296,6 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0) continue; } - // Preprocessor should ensure code doesn't contain any extended ascii / utf / etc. - assert(CurrentToken.empty() || (CurrentToken[0] & 0x80) == 0); - if (ch == '.' && !CurrentToken.empty() && std::isdigit(CurrentToken[0])) { diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index a1d72f51e..367075157 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -2647,7 +2647,7 @@ private: Settings settings; Preprocessor preprocessor(&settings, this); preprocessor.read(istr, "test.cpp"); - ASSERT_EQUALS("[test.cpp:1]: (error) The code contains characters that are unhandled. Neither unicode nor extended ASCII are supported. (line=1, character code=c8)\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (error) The code contains unhandled characters (character code = 0xc8). Checking continues, but do not expect valid results.\n", errout.str()); } void unicodeInComment() {