Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #352 - default to latest standard if none is provided #356

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
static bool isCpp17OrLater(const simplecpp::DUI &dui)
{
const std::string std_ver = simplecpp::getCppStdString(dui.std);
return !std_ver.empty() && (std_ver >= "201703L");
return std_ver.empty() || (std_ver >= "201703L");
}

static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader);
Expand Down
9 changes: 4 additions & 5 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,8 @@ static void has_include_1()
ASSERT_EQUALS("\n\nA", preprocess(code, dui));
dui.std = "c++14";
ASSERT_EQUALS("", preprocess(code, dui));
ASSERT_EQUALS("", preprocess(code));
// we default to latest standard
ASSERT_EQUALS("\n\nA", preprocess(code));
}

static void has_include_2()
Expand All @@ -1388,7 +1389,6 @@ static void has_include_2()
simplecpp::DUI dui;
dui.std = "c++17";
ASSERT_EQUALS("\n\nA", preprocess(code, dui));
ASSERT_EQUALS("", preprocess(code));
}

static void has_include_3()
Expand All @@ -1407,7 +1407,6 @@ static void has_include_3()
// Unless -I is set (preferably, we should differentiate -I and -isystem...)
dui.includePaths.push_back("./testsuite");
ASSERT_EQUALS("\n\nA", preprocess(code, dui));
ASSERT_EQUALS("", preprocess(code));
}

static void has_include_4()
Expand All @@ -1422,7 +1421,6 @@ static void has_include_4()
simplecpp::DUI dui;
dui.std = "c++17";
ASSERT_EQUALS("\n\nA", preprocess(code, dui));
ASSERT_EQUALS("", preprocess(code));
}

static void has_include_5()
Expand All @@ -1437,7 +1435,6 @@ static void has_include_5()
simplecpp::DUI dui;
dui.std = "c++17";
ASSERT_EQUALS("\n\nA", preprocess(code, dui));
ASSERT_EQUALS("", preprocess(code));
}

static void ifdef1()
Expand Down Expand Up @@ -2647,6 +2644,7 @@ static void stdcVersionDefine()
simplecpp::DUI dui;
dui.std = "c11";
ASSERT_EQUALS("\n201112L", preprocess(code, dui));
ASSERT_EQUALS("\n202311L", preprocess(code)); // default to latest
}

static void cpluscplusDefine()
Expand All @@ -2657,6 +2655,7 @@ static void cpluscplusDefine()
simplecpp::DUI dui;
dui.std = "c++11";
ASSERT_EQUALS("\n201103L", preprocess(code, dui));
ASSERT_EQUALS("\n202400L", preprocess(code)); // default to latest
}

static void invalidStd()
Expand Down
Loading