@@ -2766,6 +2766,19 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
27662766 ValueFlow::setValues (&list, mSymbolDatabase , mErrorLogger , mSettings );
27672767 }
27682768
2769+ // Warn about unhandled character literals
2770+ if (mSettings ->severity .isEnabled (Severity::information)) {
2771+ for (const Token *tok = tokens (); tok; tok = tok->next ()) {
2772+ if (tok->tokType () == Token::eChar && tok->values ().empty ()) {
2773+ try {
2774+ simplecpp::characterLiteralToLL (tok->str ());
2775+ } catch (const std::exception &e) {
2776+ unhandledCharLiteral (tok, e.what ());
2777+ }
2778+ }
2779+ }
2780+ }
2781+
27692782 mSymbolDatabase ->setArrayDimensionsUsingValueFlow ();
27702783
27712784 printDebugOutput (1 );
@@ -9528,6 +9541,21 @@ void Tokenizer::cppcheckError(const Token *tok) const
95289541 printDebugOutput (0 );
95299542 throw InternalError (tok, " Analysis failed. If the code is valid then please report this failure." , InternalError::INTERNAL);
95309543}
9544+
9545+ void Tokenizer::unhandledCharLiteral (const Token *tok, const std::string& msg) const
9546+ {
9547+ std::string s = tok ? (" " + tok->str ()) : " " ;
9548+ for (int i = 0 ; i < s.size (); ++i) {
9549+ if ((unsigned char )s[i] >= 0x80 )
9550+ s.clear ();
9551+ }
9552+
9553+ reportError (tok,
9554+ Severity::information,
9555+ " cppcheckUnhandledChar" ,
9556+ " Character literal" + s + " is not handled. " + msg);
9557+ }
9558+
95319559/* *
95329560 * Helper function to check whether number is equal to integer constant X
95339561 * or floating point pattern X.0
0 commit comments