diff --git a/lib/importproject.cpp b/lib/importproject.cpp index f8cb07f2fc9..4f3364ae88f 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -319,8 +319,12 @@ bool ImportProject::fsParseCommand(FileSettings& fs, const std::string& command) (void)Standards::getCPP(fs.standard, unknown_std); if (unknown_std) (void)Standards::getC(fs.standard, unknown_std); if (unknown_std) { - printError("unknown --std value '" + fs.standard + "'"); - return false; + const Standards::cppstd_t gnustd = Standards::getGnuCPP(fs.standard, unknown_std); + if (unknown_std) { + printError("unknown --std value '" + fs.standard + "'"); + return false; + } + fs.standard = Standards::getCPP(gnustd); } } else if (F == 'i' && fval == "system") { ++pos; diff --git a/lib/standards.h b/lib/standards.h index 51f46633e18..5563e631791 100644 --- a/lib/standards.h +++ b/lib/standards.h @@ -149,6 +149,33 @@ struct Standards { unknown = true; return Standards::CPPLatest; } + static cppstd_t getGnuCPP(const std::string &std, bool &unknown) { + // treat gnu++XX as c++XX + unknown = false; + if (std == "gnu++03") { + return Standards::CPP03; + } + if (std == "gnu++11") { + return Standards::CPP11; + } + if (std == "gnu++14") { + return Standards::CPP14; + } + if (std == "gnu++17") { + return Standards::CPP17; + } + if (std == "gnu++20") { + return Standards::CPP20; + } + if (std == "gnu++23") { + return Standards::CPP23; + } + if (std == "gnu++26") { + return Standards::CPP26; + } + unknown = true; + return Standards::CPPLatest; + } }; /// @}