From 22de2478b4e12ed5f4982983446236e05136f0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 27 Aug 2024 21:32:05 +0200 Subject: [PATCH] treat gnu++XX as c++XX when parsing command files --- lib/importproject.cpp | 8 ++++++-- lib/standards.h | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) 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; + } }; /// @}