Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::set<s
return next1->str();
}

if (len == 3 && cond->name && next1->str() == "==" && next2->number) {
if (len == 3 && cond->name && (next1->str() == "==" || next1->str() == "<=" || next1->str() == ">=") && next2->number) {
if (defined.find(cond->str()) == defined.end())
return cond->str() + '=' + cond->next->next->str();
}
Expand Down
16 changes: 16 additions & 0 deletions test/testpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ class TestPreprocessor : public TestFixture {
TEST_CASE(getConfigs11); // #9832 - include guards
TEST_CASE(getConfigs12); // #14222
TEST_CASE(getConfigs13); // #14222
TEST_CASE(getConfigs14); // #1059
TEST_CASE(getConfigs15); // #1059
TEST_CASE(getConfigsError);

TEST_CASE(getConfigsD1);
Expand Down Expand Up @@ -2289,6 +2291,20 @@ class TestPreprocessor : public TestFixture {
ASSERT_EQUALS("\n", getConfigsStr(filedata, nullptr, "gnu.cfg"));
}

void getConfigs14() { // #1059
const char filedata[] = "#if A >= 1\n"
"1\n"
"#endif\n";
ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata));
}

void getConfigs15() { // #1059
const char filedata[] = "#if A <= 1\n"
"1\n"
"#endif\n";
ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata));
}

void getConfigsError() {
const char filedata1[] = "#ifndef X\n"
"#error \"!X\"\n"
Expand Down
Loading