diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 22386db4df9..637e49263b1 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -264,6 +264,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mUI->mActionC89->setActionGroup(mCStandardActions);
mUI->mActionC99->setActionGroup(mCStandardActions);
mUI->mActionC11->setActionGroup(mCStandardActions);
+ //mUI->mActionC17->setActionGroup(mCStandardActions);
+ //mUI->mActionC23->setActionGroup(mCStandardActions);
mUI->mActionCpp03->setActionGroup(mCppStandardActions);
mUI->mActionCpp11->setActionGroup(mCppStandardActions);
@@ -271,6 +273,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mUI->mActionCpp17->setActionGroup(mCppStandardActions);
mUI->mActionCpp20->setActionGroup(mCppStandardActions);
//mUI->mActionCpp23->setActionGroup(mCppStandardActions);
+ //mUI->mActionCpp26->setActionGroup(mCppStandardActions);
mUI->mActionEnforceC->setActionGroup(mSelectLanguageActions);
mUI->mActionEnforceCpp->setActionGroup(mSelectLanguageActions);
@@ -374,6 +377,8 @@ void MainWindow::loadSettings()
mUI->mActionC89->setChecked(standards.c == Standards::C89);
mUI->mActionC99->setChecked(standards.c == Standards::C99);
mUI->mActionC11->setChecked(standards.c == Standards::C11);
+ //mUI->mActionC17->setChecked(standards.c == Standards::C17);
+ //mUI->mActionC23->setChecked(standards.c == Standards::C23);
standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString());
mUI->mActionCpp03->setChecked(standards.cpp == Standards::CPP03);
mUI->mActionCpp11->setChecked(standards.cpp == Standards::CPP11);
@@ -381,6 +386,7 @@ void MainWindow::loadSettings()
mUI->mActionCpp17->setChecked(standards.cpp == Standards::CPP17);
mUI->mActionCpp20->setChecked(standards.cpp == Standards::CPP20);
//mUI->mActionCpp23->setChecked(standards.cpp == Standards::CPP23);
+ //mUI->mActionCpp26->setChecked(standards.cpp == Standards::CPP26);
// Main window settings
const bool showMainToolbar = mSettings->value(SETTINGS_TOOLBARS_MAIN_SHOW, true).toBool();
@@ -452,6 +458,10 @@ void MainWindow::saveSettings() const
mSettings->setValue(SETTINGS_STD_C, "C99");
if (mUI->mActionC11->isChecked())
mSettings->setValue(SETTINGS_STD_C, "C11");
+ //if (mUI->mActionC17->isChecked())
+ // mSettings->setValue(SETTINGS_STD_C, "C17");
+ //if (mUI->mActionC23->isChecked())
+ // mSettings->setValue(SETTINGS_STD_C, "C23");
if (mUI->mActionCpp03->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++03");
@@ -465,6 +475,8 @@ void MainWindow::saveSettings() const
mSettings->setValue(SETTINGS_STD_CPP, "C++20");
//if (mUI.mActionCpp23->isChecked())
// mSettings->setValue(SETTINGS_STD_CPP, "C++23");
+ //if (mUI.mActionCpp26->isChecked())
+ // mSettings->setValue(SETTINGS_STD_CPP, "C++26");
// Main window settings
mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI->mToolBarMain->isVisible());
diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui
index fc2e6cbe1af..ac533599604 100644
--- a/gui/mainwindow.ui
+++ b/gui/mainwindow.ui
@@ -203,6 +203,7 @@
+
@@ -794,6 +797,22 @@
C&11
+
+
true
@@ -915,6 +934,17 @@
C++23
+
Compliance report...
diff --git a/lib/keywords.cpp b/lib/keywords.cpp
index c990ec5afca..a26fc5bd786 100644
--- a/lib/keywords.cpp
+++ b/lib/keywords.cpp
@@ -34,24 +34,17 @@
#define C11_KEYWORDS \
"_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local"
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-macros"
-#endif
-
#define C23_KEYWORDS \
"alignas", "alignof", "bool", "constexpr", "false", "nullptr", "static_assert", "thread_local", "true", "typeof", "typeof_unqual", \
"_BitInt", "_Decimal128", "_Decimal32", "_Decimal64"
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
static const std::unordered_set c89_keywords_all = {
C90_KEYWORDS
};
-static const std::unordered_set c89_keywords = c89_keywords_all;
+static const std::unordered_set c89_keywords = {
+ C90_KEYWORDS
+};
static const std::unordered_set c99_keywords_all = {
C90_KEYWORDS, C99_KEYWORDS
@@ -69,6 +62,13 @@ static const std::unordered_set c11_keywords = {
C11_KEYWORDS
};
+static const std::unordered_set c17_keywords_all = {
+ C90_KEYWORDS, C99_KEYWORDS, C11_KEYWORDS
+};
+
+static const std::unordered_set c17_keywords = {
+};
+
static const std::unordered_set c23_keywords_all = {
C90_KEYWORDS, C99_KEYWORDS, C11_KEYWORDS, C23_KEYWORDS
};
@@ -118,7 +118,9 @@ static const std::unordered_set cpp03_keywords_all = {
CPP03_KEYWORDS
};
-static const std::unordered_set cpp03_keywords = cpp03_keywords_all;
+static const std::unordered_set cpp03_keywords = {
+ CPP03_KEYWORDS
+};
static const std::unordered_set cpp11_keywords_all = {
CPP03_KEYWORDS, CPP11_KEYWORDS
@@ -128,13 +130,19 @@ static const std::unordered_set cpp11_keywords = {
CPP11_KEYWORDS
};
-static const std::unordered_set cpp14_keywords_all = cpp11_keywords_all;
+static const std::unordered_set cpp14_keywords_all = {
+ CPP03_KEYWORDS, CPP11_KEYWORDS
+};
-static const std::unordered_set cpp14_keywords;
+static const std::unordered_set cpp14_keywords = {
+};
-static const std::unordered_set cpp17_keywords_all = cpp11_keywords_all;
+static const std::unordered_set cpp17_keywords_all = {
+ CPP03_KEYWORDS, CPP11_KEYWORDS
+};
-static const std::unordered_set cpp17_keywords;
+static const std::unordered_set cpp17_keywords = {
+};
static const std::unordered_set cpp20_keywords_all = {
CPP03_KEYWORDS, CPP11_KEYWORDS, CPP20_KEYWORDS
@@ -144,9 +152,19 @@ static const std::unordered_set cpp20_keywords = {
CPP20_KEYWORDS
};
-static const std::unordered_set cpp23_keywords;
+static const std::unordered_set cpp23_keywords = {
+};
+
+static const std::unordered_set cpp23_keywords_all = {
+ CPP03_KEYWORDS, CPP11_KEYWORDS, CPP20_KEYWORDS
+};
+
+static const std::unordered_set cpp26_keywords = {
+};
-static const std::unordered_set cpp23_keywords_all = cpp20_keywords_all;
+static const std::unordered_set cpp26_keywords_all = {
+ CPP03_KEYWORDS, CPP11_KEYWORDS, CPP20_KEYWORDS
+};
// cppcheck-suppress unusedFunction
const std::unordered_set& Keywords::getAll(Standards::cstd_t cStd)
@@ -158,8 +176,9 @@ const std::unordered_set& Keywords::getAll(Standards::cstd_t cStd)
case Standards::cstd_t::C99:
return c99_keywords_all;
case Standards::cstd_t::C11:
- case Standards::cstd_t::C17:
return c11_keywords_all;
+ case Standards::cstd_t::C17:
+ return c17_keywords_all;
case Standards::cstd_t::C23:
return c23_keywords_all;
}
@@ -182,6 +201,8 @@ const std::unordered_set& Keywords::getAll(Standards::cppstd_t cppS
return cpp20_keywords_all;
case Standards::cppstd_t::CPP23:
return cpp23_keywords_all;
+ case Standards::cppstd_t::CPP26:
+ return cpp26_keywords_all;
}
cppcheck::unreachable();
}
@@ -196,10 +217,11 @@ const std::unordered_set& Keywords::getOnly(Standards::cstd_t cStd)
case Standards::cstd_t::C99:
return c99_keywords;
case Standards::cstd_t::C11:
- case Standards::cstd_t::C17:
return c11_keywords;
+ case Standards::cstd_t::C17:
+ return c17_keywords;
case Standards::cstd_t::C23:
- return c23_keywords_all;
+ return c23_keywords;
}
cppcheck::unreachable();
}
@@ -221,6 +243,8 @@ const std::unordered_set& Keywords::getOnly(Standards::cppstd_t cpp
return cpp20_keywords;
case Standards::cppstd_t::CPP23:
return cpp23_keywords;
+ case Standards::cppstd_t::CPP26:
+ return cpp26_keywords;
}
cppcheck::unreachable();
}
diff --git a/lib/standards.h b/lib/standards.h
index 34d1882a067..be9752966e1 100644
--- a/lib/standards.h
+++ b/lib/standards.h
@@ -40,26 +40,16 @@ struct Standards {
enum cstd_t { C89, C99, C11, C17, C23, CLatest = C23 } c = CLatest;
/** C++ code standard */
- enum cppstd_t { CPP03, CPP11, CPP14, CPP17, CPP20, CPP23, CPPLatest = CPP23 } cpp = CPPLatest;
+ enum cppstd_t { CPP03, CPP11, CPP14, CPP17, CPP20, CPP23, CPP26, CPPLatest = CPP26 } cpp = CPPLatest;
/** --std value given on command line */
std::string stdValue;
- bool setC(const std::string& str) {
+ bool setC(std::string str) {
stdValue = str;
- if (str == "c89" || str == "C89") {
- c = C89;
- return true;
- }
- if (str == "c99" || str == "C99") {
- c = C99;
- return true;
- }
- if (str == "c11" || str == "C11") {
- c = C11;
- return true;
- }
- return false;
+ strTolower(str);
+ c = getC(str);
+ return !stdValue.empty() && str == getC();
}
std::string getC() const {
switch (c) {
@@ -117,6 +107,8 @@ struct Standards {
return "c++20";
case CPP23:
return "c++23";
+ case CPP26:
+ return "c++26";
}
return "";
}
@@ -139,6 +131,9 @@ struct Standards {
if (std == "c++23") {
return Standards::CPP23;
}
+ if (std == "c++26") {
+ return Standards::CPP26;
+ }
return Standards::CPPLatest;
}
};
diff --git a/test/fixture.h b/test/fixture.h
index 1defa6ac3af..391b5ba1963 100644
--- a/test/fixture.h
+++ b/test/fixture.h
@@ -193,7 +193,7 @@ class TestFixture : public ErrorLogger {
}
SettingsBuilder& c(Standards::cstd_t std) {
- // TODO: CLatest and C11 are the same - handle differently
+ // TODO: CLatest and C23 are the same - handle differently?
//if (REDUNDANT_CHECK && settings.standards.c == std)
// throw std::runtime_error("redundant setting: standards.c");
settings.standards.c = std;
@@ -201,7 +201,7 @@ class TestFixture : public ErrorLogger {
}
SettingsBuilder& cpp(Standards::cppstd_t std) {
- // TODO: CPPLatest and CPP20 are the same - handle differently
+ // TODO: CPPLatest and CPP26 are the same - handle differently?
//if (REDUNDANT_CHECK && settings.standards.cpp == std)
// throw std::runtime_error("redundant setting: standards.cpp");
settings.standards.cpp = std;
diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp
index 7d557c8b85b..958913895c5 100644
--- a/test/testbufferoverrun.cpp
+++ b/test/testbufferoverrun.cpp
@@ -77,8 +77,7 @@ class TestBufferOverrun : public TestFixture {
#define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__)
void checkP_(const char* file, int line, const char code[], const char* filename = "test.cpp")
{
- const Settings settings = settingsBuilder(settings0).severity(Severity::performance)
- .c(Standards::CLatest).cpp(Standards::CPPLatest).certainty(Certainty::inconclusive).build();
+ const Settings settings = settingsBuilder(settings0).severity(Severity::performance).certainty(Certainty::inconclusive).build();
std::vector files(1, filename);
Tokenizer tokenizer(settings, *this);
diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp
index a5d1bfed061..c5b962dd9c0 100644
--- a/test/testtokenize.cpp
+++ b/test/testtokenize.cpp
@@ -887,12 +887,12 @@ class TestTokenizer : public TestFixture {
const char code[] = "_Pragma(\"abc\") int x;";
const Settings s_c89 = settingsBuilder().c(Standards::C89).build();
ASSERT_EQUALS("_Pragma ( \"abc\" ) int x ;", tokenizeAndStringify(code, s_c89, false));
- const Settings s_clatest = settingsBuilder().c(Standards::CLatest).build();
+ const Settings s_clatest;
ASSERT_EQUALS("int x ;", tokenizeAndStringify(code, s_clatest, false));
const Settings s_cpp03 = settingsBuilder().cpp(Standards::CPP03).build();
ASSERT_EQUALS("_Pragma ( \"abc\" ) int x ;", tokenizeAndStringify(code, s_cpp03, true));
- const Settings s_cpplatest = settingsBuilder().cpp(Standards::CPPLatest).build();
+ const Settings s_cpplatest;
ASSERT_EQUALS("int x ;", tokenizeAndStringify(code, s_cpplatest, true));
}
diff --git a/test/testvarid.cpp b/test/testvarid.cpp
index a09da28828b..4c433962f00 100644
--- a/test/testvarid.cpp
+++ b/test/testvarid.cpp
@@ -35,7 +35,7 @@ class TestVarID : public TestFixture {
TestVarID() : TestFixture("TestVarID") {}
private:
- const Settings settings = settingsBuilder().c(Standards::C89).cpp(Standards::CPPLatest).platform(Platform::Type::Unix64).build();
+ const Settings settings = settingsBuilder().c(Standards::C89).platform(Platform::Type::Unix64).build();
void run() override {
TEST_CASE(varid1);
TEST_CASE(varid2);