@@ -1126,8 +1126,7 @@ void Tokenizer::simplifyTypedef()
11261126 if (!ts.fail () && numberOfTypedefs[ts.name ()] == 1 &&
11271127 (numberOfTypedefs.find (ts.getTypedefToken ()->strAt (1 )) == numberOfTypedefs.end () || ts.getTypedefToken ()->strAt (2 ) == " (" )) {
11281128 if (mSettings .severity .isEnabled (Severity::portability) && ts.isInvalidConstFunctionType (typedefs))
1129- reportError (tok->next (), Severity::portability, " invalidConstFunctionType" ,
1130- " It is unspecified behavior to const qualify a function type." );
1129+ invalidConstFunctionTypeError (tok->next ());
11311130 typedefs.emplace (ts.name (), ts);
11321131 if (!ts.isStructEtc ())
11331132 tok = ts.endToken ();
@@ -5743,7 +5742,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
57435742 if (isCPP () && mSettings .severity .isEnabled (Severity::information)) {
57445743 for (const Token *tok = list.front (); tok; tok = tok->next ()) {
57455744 if (Token::Match (tok, " class %type% %type% [:{]" )) {
5746- unhandled_macro_class_x_y (tok);
5745+ unhandled_macro_class_x_y (tok, tok-> str (), tok-> strAt ( 1 ), tok-> strAt ( 2 ), tok-> strAt ( 3 ) );
57475746 }
57485747 }
57495748 }
@@ -8114,16 +8113,16 @@ void Tokenizer::unknownMacroError(const Token *tok1) const
81148113 throw InternalError (tok1, " There is an unknown macro here somewhere. Configuration is required. If " + tok1->str () + " is a macro then please configure it." , InternalError::UNKNOWN_MACRO);
81158114}
81168115
8117- void Tokenizer::unhandled_macro_class_x_y (const Token *tok) const
8116+ void Tokenizer::unhandled_macro_class_x_y (const Token *tok, const std::string& type, const std::string& x, const std::string& y, const std::string& bracket ) const
81188117{
81198118 reportError (tok,
81208119 Severity::information,
81218120 " class_X_Y" ,
81228121 " The code '" +
8123- tok-> str () + " " +
8124- tok-> strAt ( 1 ) + " " +
8125- tok-> strAt ( 2 ) + " " +
8126- tok-> strAt ( 3 ) + " ' is not handled. You can use -I or --include to add handling of this code." );
8122+ type + " " +
8123+ x + " " +
8124+ y + " " +
8125+ bracket + " ' is not handled. You can use -I or --include to add handling of this code." );
81278126}
81288127
81298128void Tokenizer::macroWithSemicolonError (const Token *tok, const std::string ¯oName) const
@@ -8134,6 +8133,14 @@ void Tokenizer::macroWithSemicolonError(const Token *tok, const std::string &mac
81348133 " Ensure that '" + macroName + " ' is defined either using -I, --include or -D." );
81358134}
81368135
8136+ void Tokenizer::invalidConstFunctionTypeError (const Token *tok) const
8137+ {
8138+ reportError (tok,
8139+ Severity::portability,
8140+ " invalidConstFunctionType" ,
8141+ " It is unspecified behavior to const qualify a function type." );
8142+ }
8143+
81378144void Tokenizer::cppcheckError (const Token *tok) const
81388145{
81398146 printDebugOutput (0 , std::cout);
@@ -10908,3 +10915,13 @@ bool Tokenizer::isPacked(const Token * bodyStart) const
1090810915 return d.linenr < bodyStart->linenr () && d.str == " #pragma pack(1)" && d.file == list.getFiles ().front ();
1090910916 });
1091010917}
10918+
10919+ void Tokenizer::getErrorMessages (ErrorLogger& errorLogger, const Settings& settings)
10920+ {
10921+ Tokenizer tokenizer (settings, errorLogger);
10922+ tokenizer.invalidConstFunctionTypeError (nullptr );
10923+ // checkLibraryNoReturn
10924+ tokenizer.unhandled_macro_class_x_y (nullptr , emptyString, emptyString, emptyString, emptyString);
10925+ tokenizer.macroWithSemicolonError (nullptr , emptyString);
10926+ tokenizer.unhandledCharLiteral (nullptr , emptyString);
10927+ }
0 commit comments