Fixed #2871 (Define in source not set when -D is used)
This commit is contained in:
parent
74d086d5a0
commit
c55b0ff651
|
@ -1722,7 +1722,12 @@ std::string Preprocessor::getcode(const std::string &filedata, const std::string
|
|||
if (pos == std::string::npos)
|
||||
cfgmap[line.substr(8)] = "";
|
||||
else if (line[pos] == ' ')
|
||||
cfgmap[line.substr(8, pos - 8)] = line.substr(pos + 1);
|
||||
{
|
||||
std::string value(line.substr(pos + 1));
|
||||
if (cfgmap.find(value) != cfgmap.end())
|
||||
value = cfgmap[value];
|
||||
cfgmap[line.substr(8, pos - 8)] = value;
|
||||
}
|
||||
else
|
||||
cfgmap[line.substr(8, pos - 8)] = "";
|
||||
}
|
||||
|
|
|
@ -225,6 +225,7 @@ private:
|
|||
// Using -D to predefine symbols
|
||||
TEST_CASE(predefine1);
|
||||
TEST_CASE(predefine2);
|
||||
TEST_CASE(predefine3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2889,6 +2890,18 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void predefine3()
|
||||
{
|
||||
// #2871 - define in source is not used if -D is used
|
||||
const char code[] = "#define X 1\n"
|
||||
"#define Y X\n"
|
||||
"#if (X == Y)\n"
|
||||
"Fred & Wilma\n"
|
||||
"#endif\n";
|
||||
const Settings settings;
|
||||
const std::string actual = Preprocessor::getcode(code, "TEST", "test.c", &settings, this);
|
||||
ASSERT_EQUALS("\n\n\nFred & Wilma\n\n", actual);
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestPreprocessor)
|
||||
|
|
Loading…
Reference in New Issue