Fixed #3690 (CppCheck is stuck on evaluating false preprocessor expression( = 0))
This commit is contained in:
parent
aa4fe3a1e2
commit
e4ad193b40
|
@ -2569,7 +2569,8 @@ bool Preprocessor::validateCfg(const std::string &code, const std::string &cfg)
|
|||
if (cfg[pos2] == ';')
|
||||
macros.insert(cfg.substr(pos, pos2-pos));
|
||||
pos = cfg.find(";", pos2);
|
||||
if (pos != std::string::npos)
|
||||
if (pos == std::string::npos)
|
||||
break;
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
|
|
@ -3539,6 +3539,7 @@ private:
|
|||
Settings settings;
|
||||
Preprocessor preprocessor(&settings, this);
|
||||
|
||||
ASSERT_EQUALS(true, preprocessor.validateCfg("", "X=42")); // don't hang when parsing cfg
|
||||
ASSERT_EQUALS(false, preprocessor.validateCfg("int x=X;", "X"));
|
||||
ASSERT_EQUALS(false, preprocessor.validateCfg("X=1;", "X"));
|
||||
ASSERT_EQUALS(true, preprocessor.validateCfg("int x=X;", "Y"));
|
||||
|
|
Loading…
Reference in New Issue