@@ -1126,8 +1126,7 @@ void Tokenizer::simplifyTypedef()
1126
1126
if (!ts.fail () && numberOfTypedefs[ts.name ()] == 1 &&
1127
1127
(numberOfTypedefs.find (ts.getTypedefToken ()->strAt (1 )) == numberOfTypedefs.end () || ts.getTypedefToken ()->strAt (2 ) == " (" )) {
1128
1128
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 ());
1131
1130
typedefs.emplace (ts.name (), ts);
1132
1131
if (!ts.isStructEtc ())
1133
1132
tok = ts.endToken ();
@@ -5743,7 +5742,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
5743
5742
if (isCPP () && mSettings .severity .isEnabled (Severity::information)) {
5744
5743
for (const Token *tok = list.front (); tok; tok = tok->next ()) {
5745
5744
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 ) );
5747
5746
}
5748
5747
}
5749
5748
}
@@ -8114,16 +8113,16 @@ void Tokenizer::unknownMacroError(const Token *tok1) const
8114
8113
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);
8115
8114
}
8116
8115
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
8118
8117
{
8119
8118
reportError (tok,
8120
8119
Severity::information,
8121
8120
" class_X_Y" ,
8122
8121
" 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." );
8127
8126
}
8128
8127
8129
8128
void Tokenizer::macroWithSemicolonError (const Token *tok, const std::string ¯oName) const
@@ -8134,6 +8133,14 @@ void Tokenizer::macroWithSemicolonError(const Token *tok, const std::string &mac
8134
8133
" Ensure that '" + macroName + " ' is defined either using -I, --include or -D." );
8135
8134
}
8136
8135
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
+
8137
8144
void Tokenizer::cppcheckError (const Token *tok) const
8138
8145
{
8139
8146
printDebugOutput (0 , std::cout);
@@ -10908,3 +10915,13 @@ bool Tokenizer::isPacked(const Token * bodyStart) const
10908
10915
return d.linenr < bodyStart->linenr () && d.str == " #pragma pack(1)" && d.file == list.getFiles ().front ();
10909
10916
});
10910
10917
}
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