Fixed #10170 (Preprocessor; Fail to extract some configurations)
This commit is contained in:
parent
b7c4aeca16
commit
7ab70654ba
|
@ -459,6 +459,16 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
|
||||||
std::vector<std::string> configs(configs_if);
|
std::vector<std::string> configs(configs_if);
|
||||||
configs.push_back(configs_ifndef.back());
|
configs.push_back(configs_ifndef.back());
|
||||||
ret.erase(cfg(configs, userDefines));
|
ret.erase(cfg(configs, userDefines));
|
||||||
|
std::set<std::string> temp;
|
||||||
|
temp.swap(ret);
|
||||||
|
for (const std::string &c: temp) {
|
||||||
|
if (c.find(configs_ifndef.back()) != std::string::npos)
|
||||||
|
ret.insert(c);
|
||||||
|
else if (c.empty())
|
||||||
|
ret.insert(configs.empty() ? configs_ifndef.back() : "");
|
||||||
|
else
|
||||||
|
ret.insert(c + ";" + configs_ifndef.back());
|
||||||
|
}
|
||||||
if (!elseError.empty())
|
if (!elseError.empty())
|
||||||
elseError += ';';
|
elseError += ';';
|
||||||
elseError += cfg(configs_ifndef, userDefines);
|
elseError += cfg(configs_ifndef, userDefines);
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
TEST_CASE(error5);
|
TEST_CASE(error5);
|
||||||
TEST_CASE(error6);
|
TEST_CASE(error6);
|
||||||
TEST_CASE(error7);
|
TEST_CASE(error7);
|
||||||
|
TEST_CASE(error8); // #10170 -> previous #if configurations
|
||||||
|
|
||||||
TEST_CASE(setPlatformInfo);
|
TEST_CASE(setPlatformInfo);
|
||||||
|
|
||||||
|
@ -427,6 +428,19 @@ private:
|
||||||
ASSERT_EQUALS("\nB\n", getConfigsStr(filedata));
|
ASSERT_EQUALS("\nB\n", getConfigsStr(filedata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void error8() {
|
||||||
|
const char filedata[] = "#ifdef A\n"
|
||||||
|
"#ifdef B\n"
|
||||||
|
"#endif\n"
|
||||||
|
"#else\n"
|
||||||
|
"#endif\n"
|
||||||
|
"\n"
|
||||||
|
"#ifndef C\n"
|
||||||
|
"#error aa\n"
|
||||||
|
"#endif";
|
||||||
|
ASSERT_EQUALS("A;B;C\nA;C\nC\n", getConfigsStr(filedata));
|
||||||
|
}
|
||||||
|
|
||||||
void setPlatformInfo() {
|
void setPlatformInfo() {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
Preprocessor preprocessor(settings, this);
|
Preprocessor preprocessor(settings, this);
|
||||||
|
@ -2134,7 +2148,7 @@ private:
|
||||||
"#error \"!Y\"\n"
|
"#error \"!Y\"\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"#endif\n";
|
"#endif\n";
|
||||||
ASSERT_EQUALS("\nX\nY\n", getConfigsStr(filedata2));
|
ASSERT_EQUALS("\nX;Y\nY\n", getConfigsStr(filedata2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void getConfigsD1() {
|
void getConfigsD1() {
|
||||||
|
|
Loading…
Reference in New Issue