Preprocessor::getConfigs: Better handling of ! in #if
This commit is contained in:
parent
b7dcdc00d0
commit
edd1c32e5b
|
@ -196,8 +196,14 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::set<s
|
|||
|
||||
std::set<std::string> configset;
|
||||
for (; sameline(iftok,cond); cond = cond->next) {
|
||||
if (cond->op == '!')
|
||||
if (cond->op == '!') {
|
||||
if (!sameline(iftok,cond->next) || !cond->next->name)
|
||||
break;
|
||||
if (cond->next->str == "defined")
|
||||
continue;
|
||||
configset.insert(cond->next->str + "=0");
|
||||
continue;
|
||||
}
|
||||
if (cond->str != "defined")
|
||||
continue;
|
||||
const simplecpp::Token *dtok = cond->next;
|
||||
|
|
|
@ -558,7 +558,7 @@ private:
|
|||
"#elif !defined(B)\n"
|
||||
"!b\n"
|
||||
"#endif\n";
|
||||
TODO_ASSERT_EQUALS("\nA\nA;B", "\n", getConfigsStr(filedata));
|
||||
ASSERT_EQUALS("\nA\nB\n", getConfigsStr(filedata));
|
||||
}
|
||||
|
||||
void if_cond3() {
|
||||
|
@ -612,7 +612,7 @@ private:
|
|||
const char filedata[] = "#if! A\n"
|
||||
"foo();\n"
|
||||
"#endif\n";
|
||||
ASSERT_EQUALS("\n", getConfigsStr(filedata));
|
||||
ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,7 +645,7 @@ private:
|
|||
const char filedata[] = "#if !defined _A\n"
|
||||
"abc\n"
|
||||
"#endif\n";
|
||||
ASSERT_EQUALS("\n", getConfigsStr(filedata));
|
||||
ASSERT_EQUALS("\n_A\n", getConfigsStr(filedata));
|
||||
}
|
||||
|
||||
void if_cond10() {
|
||||
|
|
Loading…
Reference in New Issue