@@ -1142,11 +1142,23 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
11421142 try {
11431143 TokenList tokenlist{mSettings , file.lang ()};
11441144
1145- // Create tokens, skip rest of iteration if failed
1146- Timer::run (" Tokenizer::createTokens" , mSettings .showtime , &s_timerResults, [&]() {
1147- simplecpp::TokenList tokensP = preprocessor.preprocess (currentConfig, files, true );
1148- tokenlist.createTokens (std::move (tokensP));
1149- });
1145+ try {
1146+ // Create tokens, skip rest of iteration if failed
1147+ Timer::run (" Tokenizer::createTokens" , mSettings .showtime , &s_timerResults, [&]() {
1148+ simplecpp::TokenList tokensP = preprocessor.preprocess (currentConfig, files, true );
1149+ tokenlist.createTokens (std::move (tokensP));
1150+ });
1151+ } catch (const simplecpp::Output &o) {
1152+ // #error etc during preprocessing
1153+ configurationError.push_back ((currentConfig.empty () ? " \'\' " : currentConfig) + " : [" + o.location .file () + ' :' + std::to_string (o.location .line ) + " ] " + o.msg );
1154+ --checkCount; // don't count invalid configurations
1155+
1156+ if (!hasValidConfig && currCfg == *configurations.rbegin ()) {
1157+ // If there is no valid configuration then report error..
1158+ preprocessor.error (o.location .file (), o.location .line , o.location .col , o.msg , o.type );
1159+ }
1160+ continue ;
1161+ }
11501162 hasValidConfig = true ;
11511163
11521164 Tokenizer tokenizer (std::move (tokenlist), mErrorLogger );
@@ -1215,17 +1227,6 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
12151227 ErrorMessage errmsg = ErrorMessage::fromInternalError (e, &tokenizer.list , file.spath ());
12161228 mErrorLogger .reportErr (errmsg);
12171229 }
1218- } catch (const simplecpp::Output &o) {
1219- // #error etc during preprocessing
1220- configurationError.push_back ((currentConfig.empty () ? " \'\' " : currentConfig) + " : [" + o.location .file () + ' :' + std::to_string (o.location .line ) + " ] " + o.msg );
1221- --checkCount; // don't count invalid configurations
1222-
1223- if (!hasValidConfig && currCfg == *configurations.rbegin ()) {
1224- // If there is no valid configuration then report error..
1225- preprocessor.error (o.location .file (), o.location .line , o.location .col , o.msg , o.type );
1226- }
1227- continue ;
1228-
12291230 } catch (const TerminateException &) {
12301231 // Analysis is terminated
12311232 if (analyzerInformation)
0 commit comments