fixed some "Variable can be made constexpr" Rider warnings (#5615)

This commit is contained in:
Oliver Stöneberg 2023-11-03 09:55:44 +01:00 committed by GitHub
parent 9280b5d7a5
commit 63e00ea918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 600 additions and 600 deletions

View File

@ -51,9 +51,9 @@
// TODO: __USE_DYNAMIC_STACK_SIZE is dependent on the features.h include and not a built-in compiler define, so it might be problematic to depend on it
#ifdef __USE_DYNAMIC_STACK_SIZE
static const size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
static constexpr size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
#else
static const size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
static constexpr size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
#endif
static char mytstack[MYSTACKSIZE]= {0}; // alternative stack for signal handler
static bool bStackBelowHeap=false; // lame attempt to locate heap vs. stack address space. See CppCheckExecutor::check_wrapper()

View File

@ -35,7 +35,7 @@ void print_stacktrace(FILE* output, bool demangling, int maxdepth, bool lowMem)
const int fd = fileno(output);
void *callstackArray[32]= {nullptr}; // the less resources the better...
const int currentdepth = backtrace(callstackArray, (int)getArrayLength(callstackArray));
const int offset=2; // some entries on top are within our own exception handling code or libc
constexpr int offset=2; // some entries on top are within our own exception handling code or libc
if (maxdepth<0)
maxdepth=currentdepth-offset;
else

View File

@ -271,13 +271,14 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mUI->mActionEnforceCpp->setActionGroup(mSelectLanguageActions);
mUI->mActionAutoDetectLanguage->setActionGroup(mSelectLanguageActions);
// TODO: we no longer default to a Windows platform in CLI - so we should probably also get rid of this in the GUI
// For Windows platforms default to Win32 checked platform.
// For other platforms default to unspecified/default which means the
// platform Cppcheck GUI was compiled on.
#if defined(_WIN32)
const Platform::Type defaultPlatform = Platform::Type::Win32W;
constexpr Platform::Type defaultPlatform = Platform::Type::Win32W;
#else
const Platform::Type defaultPlatform = Platform::Type::Unspecified;
constexpr Platform::Type defaultPlatform = Platform::Type::Unspecified;
#endif
PlatformData &platform = mPlatforms.get((Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt());
platform.mActMainWindow->setChecked(true);

View File

@ -57,12 +57,12 @@
#include <QVariant>
#include <QtCore>
static const char ADDON_MISRA[] = "misra";
static const char CODING_STANDARD_MISRA_C_2023[] = "misra-c-2023";
static const char CODING_STANDARD_MISRA_CPP_2008[] = "misra-cpp-2008";
static const char CODING_STANDARD_CERT_C[] = "cert-c-2016";
static const char CODING_STANDARD_CERT_CPP[] = "cert-cpp-2016";
static const char CODING_STANDARD_AUTOSAR[] = "autosar";
static constexpr char ADDON_MISRA[] = "misra";
static constexpr char CODING_STANDARD_MISRA_C_2023[] = "misra-c-2023";
static constexpr char CODING_STANDARD_MISRA_CPP_2008[] = "misra-cpp-2008";
static constexpr char CODING_STANDARD_CERT_C[] = "cert-c-2016";
static constexpr char CODING_STANDARD_CERT_CPP[] = "cert-cpp-2016";
static constexpr char CODING_STANDARD_AUTOSAR[] = "autosar";
/** Return paths from QListWidget */
static QStringList getPaths(const QListWidget *list)
@ -77,7 +77,7 @@ static QStringList getPaths(const QListWidget *list)
}
/** Platforms shown in the platform combobox */
static const Platform::Type builtinPlatforms[] = {
static constexpr Platform::Type builtinPlatforms[] = {
Platform::Type::Native,
Platform::Type::Win32A,
Platform::Type::Win32W,
@ -86,7 +86,7 @@ static const Platform::Type builtinPlatforms[] = {
Platform::Type::Unix64
};
static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
static constexpr int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName)
{

View File

@ -60,25 +60,25 @@
#include <QVariantMap>
#include <Qt>
static const char COLUMN[] = "column";
static const char CWE[] = "cwe";
static const char ERRORID[] = "id";
static const char FILENAME[] = "file";
static const char FILE0[] = "file0";
static const char HASH[] = "hash";
static const char HIDE[] = "hide";
static const char INCONCLUSIVE[] = "inconclusive";
static const char LINE[] = "line";
static const char MESSAGE[] = "message";
static const char SEVERITY[] = "severity";
static const char SINCEDATE[] = "sinceDate";
static const char SYMBOLNAMES[] = "symbolNames";
static const char SUMMARY[] = "summary";
static const char TAGS[] = "tags";
static constexpr char COLUMN[] = "column";
static constexpr char CWE[] = "cwe";
static constexpr char ERRORID[] = "id";
static constexpr char FILENAME[] = "file";
static constexpr char FILE0[] = "file0";
static constexpr char HASH[] = "hash";
static constexpr char HIDE[] = "hide";
static constexpr char INCONCLUSIVE[] = "inconclusive";
static constexpr char LINE[] = "line";
static constexpr char MESSAGE[] = "message";
static constexpr char SEVERITY[] = "severity";
static constexpr char SINCEDATE[] = "sinceDate";
static constexpr char SYMBOLNAMES[] = "symbolNames";
static constexpr char SUMMARY[] = "summary";
static constexpr char TAGS[] = "tags";
// These must match column headers given in ResultsTree::translate()
static const int COLUMN_SINCE_DATE = 6;
static const int COLUMN_TAGS = 7;
static constexpr int COLUMN_SINCE_DATE = 6;
static constexpr int COLUMN_TAGS = 7;
ResultsTree::ResultsTree(QWidget * parent) :
QTreeView(parent)

View File

@ -240,7 +240,7 @@ protected:
private:
void manageStyleControls();
static const int mLangCodeRole = Qt::UserRole;
static constexpr int mLangCodeRole = Qt::UserRole;
bool mPremium;
};

View File

@ -29,8 +29,8 @@
#include <QStringRef>
#endif
static const char ResultElementName[] = "results";
static const char VersionAttribute[] = "version";
static constexpr char ResultElementName[] = "results";
static constexpr char VersionAttribute[] = "version";
XmlReport::XmlReport(const QString &filename) :
Report(filename)

View File

@ -52,9 +52,9 @@ R calculate(const std::string& s, const T& x, const T& y, bool* error = nullptr)
auto wrap = [](T z) {
return R{z};
};
const MathLib::bigint maxBitsShift = sizeof(MathLib::bigint) * 8;
constexpr MathLib::bigint maxBitsShift = sizeof(MathLib::bigint) * 8;
// For portability we cannot shift signed integers by 63 bits
const MathLib::bigint maxBitsSignedShift = maxBitsShift - 1;
constexpr MathLib::bigint maxBitsSignedShift = maxBitsShift - 1;
switch (MathLib::encodeMultiChar(s)) {
case '+':
return wrap(x + y);

View File

@ -1117,8 +1117,7 @@ void CheckClass::missingMemberCopyError(const Token *tok, Function::Type functio
const std::string message =
"$symbol:" + classname + "::" + varname + "\n" +
"Member variable '$symbol' is not assigned in the " + ctor + " constructor. Should it be " + action;
const char id[] = "missingMemberCopy";
reportError(tok, Severity::warning, id, message, CWE398, Certainty::inconclusive);
reportError(tok, Severity::warning, "missingMemberCopy", message, CWE398, Certainty::inconclusive);
}
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive)

View File

@ -54,8 +54,8 @@ static const CWE CWE672(672U);
static const CWE CWE415(415U);
// Hardcoded allocation types (not from library)
static const int NEW_ARRAY = -2;
static const int NEW = -1;
static constexpr int NEW_ARRAY = -2;
static constexpr int NEW = -1;
static const std::array<std::pair<std::string, std::string>, 4> alloc_failed_conds {{{"==", "0"}, {"<", "0"}, {"==", "-1"}, {"<=", "-1"}}};
static const std::array<std::pair<std::string, std::string>, 4> alloc_success_conds {{{"!=", "0"}, {">", "0"}, {"!=", "-1"}, {">=", "0"}}};
@ -304,9 +304,9 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
static const nonneg int recursiveLimit = 300;
#elif defined(__MINGW32__)
// testrunner crashes with stack overflow in CI
static const nonneg int recursiveLimit = 600;
static constexpr nonneg int recursiveLimit = 600;
#else
static const nonneg int recursiveLimit = 1000;
static constexpr nonneg int recursiveLimit = 1000;
#endif
if (++recursiveCount > recursiveLimit) // maximum number of "else if ()"
throw InternalError(startToken, "Internal limit: CheckLeakAutoVar::checkScope() Maximum recursive count of 1000 reached.", InternalError::LIMIT);

View File

@ -3960,9 +3960,9 @@ void CheckOther::checkOverlappingWrite()
if (nonOverlappingData->sizeArg <= 0 || nonOverlappingData->sizeArg > args.size()) {
if (nonOverlappingData->sizeArg == -1) {
ErrorPath errorPath;
const bool macro = true;
const bool pure = true;
const bool follow = true;
constexpr bool macro = true;
constexpr bool pure = true;
constexpr bool follow = true;
if (!isSameExpression(mTokenizer->isCPP(), macro, ptr1, ptr2, mSettings->library, pure, follow, &errorPath))
continue;
overlappingWriteFunction(tok);
@ -3985,9 +3985,9 @@ void CheckOther::checkOverlappingWrite()
continue;
ErrorPath errorPath;
const bool macro = true;
const bool pure = true;
const bool follow = true;
constexpr bool macro = true;
constexpr bool pure = true;
constexpr bool follow = true;
if (!isSameExpression(mTokenizer->isCPP(), macro, buf1, buf2, mSettings->library, pure, follow, &errorPath))
continue;
overlappingWriteFunction(tok);

View File

@ -140,7 +140,7 @@ void CheckString::checkAlwaysTrueOrFalseStringCompare()
void CheckString::alwaysTrueFalseStringCompareError(const Token *tok, const std::string& str1, const std::string& str2)
{
const std::size_t stringLen = 10;
constexpr std::size_t stringLen = 10;
const std::string string1 = (str1.size() < stringLen) ? str1 : (str1.substr(0, stringLen-2) + "..");
const std::string string2 = (str2.size() < stringLen) ? str2 : (str2.substr(0, stringLen-2) + "..");

View File

@ -112,7 +112,7 @@ void CheckType::checkTooBigBitwiseShift()
void CheckType::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
{
const char id[] = "shiftTooManyBits";
constexpr char id[] = "shiftTooManyBits";
if (!tok) {
reportError(tok, Severity::error, id, "Shifting 32-bit value by 40 bits is undefined behaviour", CWE758, Certainty::normal);
@ -131,7 +131,7 @@ void CheckType::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const Val
void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
{
const char id[] = "shiftTooManyBitsSigned";
constexpr char id[] = "shiftTooManyBitsSigned";
const bool cpp14 = mSettings->standards.cpp >= Standards::CPP14;

View File

@ -81,10 +81,10 @@
class SymbolDatabase;
static const char Version[] = CPPCHECK_VERSION_STRING;
static const char ExtraVersion[] = "";
static constexpr char Version[] = CPPCHECK_VERSION_STRING;
static constexpr char ExtraVersion[] = "";
static const char FILELIST[] = "cppcheck-addon-ctu-file-list";
static constexpr char FILELIST[] = "cppcheck-addon-ctu-file-list";
static TimerResults s_timerResults;
@ -1636,9 +1636,9 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings)
const std::string allDefines = getDefinesFlags(fileSettings.defines);
#ifdef _WIN32
const char exe[] = "clang-tidy.exe";
constexpr char exe[] = "clang-tidy.exe";
#else
const char exe[] = "clang-tidy";
constexpr char exe[] = "clang-tidy";
#endif
const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename + "\" -- " + allIncludes + allDefines;

View File

@ -39,21 +39,21 @@
#include <tinyxml2.h>
//---------------------------------------------------------------------------
static const char ATTR_CALL_ID[] = "call-id";
static const char ATTR_CALL_FUNCNAME[] = "call-funcname";
static const char ATTR_CALL_ARGNR[] = "call-argnr";
static const char ATTR_CALL_ARGEXPR[] = "call-argexpr";
static const char ATTR_CALL_ARGVALUETYPE[] = "call-argvaluetype";
static const char ATTR_CALL_ARGVALUE[] = "call-argvalue";
static const char ATTR_WARNING[] = "warning";
static const char ATTR_LOC_FILENAME[] = "file";
static const char ATTR_LOC_LINENR[] = "line";
static const char ATTR_LOC_COLUMN[] = "col";
static const char ATTR_INFO[] = "info";
static const char ATTR_MY_ID[] = "my-id";
static const char ATTR_MY_ARGNR[] = "my-argnr";
static const char ATTR_MY_ARGNAME[] = "my-argname";
static const char ATTR_VALUE[] = "value";
static constexpr char ATTR_CALL_ID[] = "call-id";
static constexpr char ATTR_CALL_FUNCNAME[] = "call-funcname";
static constexpr char ATTR_CALL_ARGNR[] = "call-argnr";
static constexpr char ATTR_CALL_ARGEXPR[] = "call-argexpr";
static constexpr char ATTR_CALL_ARGVALUETYPE[] = "call-argvaluetype";
static constexpr char ATTR_CALL_ARGVALUE[] = "call-argvalue";
static constexpr char ATTR_WARNING[] = "warning";
static constexpr char ATTR_LOC_FILENAME[] = "file";
static constexpr char ATTR_LOC_LINENR[] = "line";
static constexpr char ATTR_LOC_COLUMN[] = "col";
static constexpr char ATTR_INFO[] = "info";
static constexpr char ATTR_MY_ID[] = "my-id";
static constexpr char ATTR_MY_ARGNR[] = "my-argnr";
static constexpr char ATTR_MY_ARGNAME[] = "my-argname";
static constexpr char ATTR_VALUE[] = "value";
int CTU::maxCtuDepth = 2;

View File

@ -60,11 +60,11 @@ static constexpr bool caseInsensitiveFilesystem()
std::string Path::toNativeSeparators(std::string path)
{
#if defined(_WIN32)
const char separ = '/';
const char native = '\\';
constexpr char separ = '/';
constexpr char native = '\\';
#else
const char separ = '\\';
const char native = '/';
constexpr char separ = '\\';
constexpr char native = '/';
#endif
std::replace(path.begin(), path.end(), separ, native);
return path;
@ -72,8 +72,8 @@ std::string Path::toNativeSeparators(std::string path)
std::string Path::fromNativeSeparators(std::string path)
{
const char nonnative = '\\';
const char newsepar = '/';
constexpr char nonnative = '\\';
constexpr char newsepar = '/';
std::replace(path.begin(), path.end(), nonnative, newsepar);
return path;
}
@ -250,9 +250,9 @@ std::string Path::getAbsoluteFilePath(const std::string& filePath)
std::string Path::stripDirectoryPart(const std::string &file)
{
#if defined(_WIN32) && !defined(__MINGW32__)
const char native = '\\';
constexpr char native = '\\';
#else
const char native = '/';
constexpr char native = '/';
#endif
const std::string::size_type p = file.rfind(native);

View File

@ -171,7 +171,7 @@ void Summaries::loadReturn(const std::string &buildDir, std::set<std::string> &s
std::string line;
while (std::getline(fin, line)) {
// Get function name
const std::string::size_type pos1 = 0;
constexpr std::string::size_type pos1 = 0;
const std::string::size_type pos2 = line.find(' ', pos1);
const std::string functionName = (pos2 == std::string::npos) ? line : line.substr(0, pos2);
std::vector<std::string> call = getSummaryData(line, "call");

View File

@ -3763,7 +3763,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime)
mTokenizer.calculateScopes();
unsigned int passCount = 0;
const unsigned int passCountMax = 10;
constexpr unsigned int passCountMax = 10;
for (; passCount < passCountMax; ++passCount) {
if (passCount) {
// it may take more than one pass to simplify type aliases

View File

@ -43,7 +43,7 @@
// How many compileExpression recursions are allowed?
// For practical code this could be endless. But in some special torture test
// there needs to be a limit.
static const int AST_MAX_DEPTH = 150;
static constexpr int AST_MAX_DEPTH = 150;
TokenList::TokenList(const Settings* settings) :

View File

@ -407,7 +407,7 @@ static ValueFlow::Value castValue(ValueFlow::Value value, const ValueType::Sign
}
}
if (bit < MathLib::bigint_bits) {
const MathLib::biguint one = 1;
constexpr MathLib::biguint one = 1;
value.intvalue &= (one << bit) - 1;
if (sign == ValueType::Sign::SIGNED && value.intvalue & (one << (bit - 1))) {
value.intvalue |= ~((one << bit) - 1ULL);
@ -3158,7 +3158,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
}
void setupExprVarIds(const Token* start, int depth = 0) {
const int maxDepth = 4;
constexpr int maxDepth = 4;
if (depth > maxDepth)
return;
visitAstNodes(start, [&](const Token* tok) {
@ -8459,7 +8459,7 @@ struct IteratorConditionHandler : SimpleConditionHandler {
if (!tok->astOperand1() || !tok->astOperand2())
return {};
const ValueFlow::Value::ValueKind kind = ValueFlow::Value::ValueKind::Known;
constexpr ValueFlow::Value::ValueKind kind = ValueFlow::Value::ValueKind::Known;
std::list<ValueFlow::Value> values = getIteratorValues(tok->astOperand1()->values(), &kind);
if (!values.empty()) {
cond.vartok = tok->astOperand2();

View File

@ -33,7 +33,7 @@ private:
}
void getAnalyzerInfoFile() const {
const char filesTxt[] = "file1.a4::file1.c\n";
constexpr char filesTxt[] = "file1.a4::file1.c\n";
std::istringstream f1(filesTxt);
ASSERT_EQUALS("file1.a4", getAnalyzerInfoFileFromFilesTxt(f1, "file1.c", ""));
std::istringstream f2(filesTxt);

View File

@ -3597,7 +3597,7 @@ private:
}
void buffer_overrun_readSizeFromCfg() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <podtype name=\"u8\" sign=\"u\" size=\"1\"/>\n"
" <function name=\"mystrcpy\">\n"
@ -4149,7 +4149,7 @@ private:
// extracttests.disable
void minsize_argvalue() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"mymemset\">\n"
" <noreturn>false</noreturn>\n"
@ -4286,7 +4286,7 @@ private:
}
void minsize_sizeof() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"mystrncpy\">\n"
" <noreturn>false</noreturn>\n"
@ -4346,7 +4346,7 @@ private:
}
void minsize_strlen() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"mysprintf\">\n"
" <noreturn>false</noreturn>\n"
@ -4459,7 +4459,7 @@ private:
}
void minsize_mul() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"myfread\">\n"
" <arg nr=\"1\">\n"

View File

@ -3444,7 +3444,7 @@ private:
}
void memsetOnStdPodType() { // Ticket #5901
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <podtype name=\"std::uint8_t\" sign=\"u\" size=\"1\"/>\n"
" <podtype name=\"std::atomic_bool\"/>\n"

View File

@ -1296,7 +1296,7 @@ private:
}
void checkIgnoredReturnValue() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def version=\"2\">\n"
" <function name=\"mystrcmp,foo::mystrcmp\">\n"
" <use-retval/>\n"

View File

@ -112,7 +112,7 @@ private:
}
void importCompileCommands1() const {
const char json[] = R"([{
constexpr char json[] = R"([{
"directory": "/tmp",
"command": "gcc -DTEST1 -DTEST2=2 -o /tmp/src.o -c /tmp/src.c",
"file": "/tmp/src.c"
@ -138,7 +138,7 @@ private:
ASSERT_EQUALS(1, importer.fileSettings.size());
ASSERT_EQUALS("C:/bar.c", importer.fileSettings.cbegin()->filename);
#else
const char json[] = R"([{
constexpr char json[] = R"([{
"directory": "/foo",
"command": "gcc -c bar.c",
"file": "/bar.c"
@ -165,7 +165,7 @@ private:
}
void importCompileCommands4() const {
const char json[] = R"([{
constexpr char json[] = R"([{
"directory": "/tmp/",
"command": "gcc -c src.mm",
"file": "src.mm"
@ -177,7 +177,7 @@ private:
}
void importCompileCommands5() const {
const char json[] =
constexpr char json[] =
R"([{
"directory": "C:/Users/dan/git/build-test-cppcheck-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug",
"command": "C:\\PROGRA~2\\MICROS~1\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1427~1.291\\bin\\HostX64\\x64\\cl.exe /nologo /TP -IC:\\Users\\dan\\git\\test-cppcheck\\mylib\\src /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /Fomylib\\CMakeFiles\\mylib.dir\\src\\foobar\\mylib.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\dan\\git\\test-cppcheck\\mylib\\src\\foobar\\mylib.cpp",
@ -196,7 +196,7 @@ private:
}
void importCompileCommands6() const {
const char json[] =
constexpr char json[] =
R"([{
"directory": "C:/Users/dan/git/build-test-cppcheck-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug",
"command": "C:\\PROGRA~2\\MICROS~1\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1427~1.291\\bin\\HostX64\\x64\\cl.exe /nologo /TP -IC:\\Users\\dan\\git\\test-cppcheck\\mylib\\src -I\"C:\\Users\\dan\\git\\test-cppcheck\\mylib\\second src\" /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /Fomylib\\CMakeFiles\\mylib.dir\\src\\foobar\\mylib.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\dan\\git\\test-cppcheck\\mylib\\src\\foobar\\mylib.cpp",
@ -218,7 +218,7 @@ private:
void importCompileCommands7() const {
// cmake -DFILESDIR="/some/path" ..
const char json[] =
constexpr char json[] =
R"([{
"directory": "/home/danielm/cppcheck 2/b/lib",
"command": "/usr/bin/c++ -DFILESDIR=\\\"/some/path\\\" -I\"/home/danielm/cppcheck 2/b/lib\" -isystem \"/home/danielm/cppcheck 2/externals\" \"/home/danielm/cppcheck 2/lib/astutils.cpp\"",
@ -238,7 +238,7 @@ private:
void importCompileCommands8() const {
// cmake -DFILESDIR="C:\Program Files\Cppcheck" -G"NMake Makefiles" ..
const char json[] =
constexpr char json[] =
R"([{
"directory": "C:/Users/danielm/cppcheck/build/lib",
"command": "C:\\PROGRA~2\\MICROS~2\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1412~1.258\\bin\\Hostx64\\x64\\cl.exe /nologo /TP -DFILESDIR=\"\\\"C:\\Program Files\\Cppcheck\\\"\" -IC:\\Users\\danielm\\cppcheck\\build\\lib -IC:\\Users\\danielm\\cppcheck\\lib -c C:\\Users\\danielm\\cppcheck\\lib\\astutils.cpp",
@ -251,7 +251,7 @@ private:
void importCompileCommands9() const {
// IAR output (https://sourceforge.net/p/cppcheck/discussion/general/thread/608af51e0a/)
const char json[] =
constexpr char json[] =
R"([{
"arguments" : [
"powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File d:\\Projekte\\xyz\\firmware\\app\\xyz-lib\\build.ps1 -IAR -COMPILER_PATH \"c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 9.0\" -CONTROLLER CC1310F128 -LIB LIB_PERMANENT -COMPILER_DEFINES \"CC1310_HFXO_FREQ=24000000 DEBUG\""
@ -266,7 +266,7 @@ private:
}
void importCompileCommands10() const { // #10887
const char json[] =
constexpr char json[] =
R"([{
"file": "/home/danielm/cppcheck/1/test folder/1.c" ,
"directory": "",
@ -285,7 +285,7 @@ private:
}
void importCompileCommands11() const { // include path order
const char json[] =
constexpr char json[] =
R"([{
"file": "1.c" ,
"directory": "/x",
@ -307,7 +307,7 @@ private:
}
void importCompileCommandsArgumentsSection() const {
const char json[] = "[ { \"directory\": \"/tmp/\","
constexpr char json[] = "[ { \"directory\": \"/tmp/\","
"\"arguments\": [\"gcc\", \"-c\", \"src.c\"],"
"\"file\": \"src.c\" } ]";
std::istringstream istr(json);
@ -318,7 +318,7 @@ private:
}
void importCompileCommandsNoCommandSection() const {
const char json[] = "[ { \"directory\": \"/tmp/\","
constexpr char json[] = "[ { \"directory\": \"/tmp/\","
"\"file\": \"src.mm\" } ]";
std::istringstream istr(json);
TestImporter importer;
@ -327,7 +327,7 @@ private:
}
void importCppcheckGuiProject() const {
const char xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
constexpr char xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<project version=\"1\">\n"
" <root name=\".\"/>\n"
" <builddir>out1</builddir>\n"

View File

@ -39,7 +39,7 @@ private:
Settings settings;
void run() override {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <podtype name=\"uint8_t\" sign=\"u\" size=\"1\"/>\n"
" <memory>\n"
@ -2777,7 +2777,7 @@ private:
}
void functionCallCastConfig() { // #9652
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def format=\"2\">\n"
" <function name=\"free_func\">\n"
" <noreturn>false</noreturn>\n"
@ -2814,7 +2814,7 @@ private:
}
void functionCallLeakIgnoreConfig() { // #7923
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def format=\"2\">\n"
" <function name=\"SomeClass::someMethod\">\n"
" <leak-ignore/>\n"

View File

@ -102,14 +102,14 @@ private:
void empty() const {
// Reading an empty library file is considered to be OK
const char xmldata[] = "<?xml version=\"1.0\"?>\n<def/>";
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n<def/>";
Library library;
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
ASSERT(library.functions.empty());
}
void function() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <noreturn>false</noreturn>\n"
@ -129,7 +129,7 @@ private:
}
void function_match_scope() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"/>"
@ -155,7 +155,7 @@ private:
}
void function_match_args() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"/>"
@ -174,7 +174,7 @@ private:
}
void function_match_args_default() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"/>"
@ -224,7 +224,7 @@ private:
}
void function_match_var() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"/>"
@ -243,7 +243,7 @@ private:
}
void function_arg() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"><not-uninit/></arg>\n"
@ -266,7 +266,7 @@ private:
}
void function_arg_any() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
"<function name=\"foo\">\n"
" <arg nr=\"any\"><not-uninit/></arg>\n"
@ -279,7 +279,7 @@ private:
}
void function_arg_variadic() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
"<function name=\"foo\">\n"
" <arg nr=\"1\"></arg>\n"
@ -303,7 +303,7 @@ private:
}
void function_arg_direction() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
"<function name=\"foo\">\n"
" <arg nr=\"1\" direction=\"in\"></arg>\n"
@ -328,7 +328,7 @@ private:
}
void function_arg_valid() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"><valid>1:</valid></arg>\n"
@ -476,7 +476,7 @@ private:
}
void function_arg_minsize() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\"><minsize type=\"strlen\" arg=\"2\"/></arg>\n"
@ -539,7 +539,7 @@ private:
}
void function_namespace() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"Foo::foo,bar\">\n"
" <noreturn>false</noreturn>\n"
@ -568,7 +568,7 @@ private:
}
void function_method() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"CString::Format\">\n"
" <noreturn>false</noreturn>\n"
@ -595,7 +595,7 @@ private:
}
void function_baseClassMethod() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"Base::f\">\n"
" <arg nr=\"1\"><not-null/></arg>\n"
@ -621,7 +621,7 @@ private:
}
void function_warn() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"a\">\n"
" <warn severity=\"style\" cstd=\"c99\">Message</warn>\n"
@ -657,7 +657,7 @@ private:
}
void memory() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <memory>\n"
" <alloc>CreateX</alloc>\n"
@ -677,14 +677,14 @@ private:
ASSERT(df && df->arg == 1);
}
void memory2() const {
const char xmldata1[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata1[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <memory>\n"
" <alloc>malloc</alloc>\n"
" <dealloc>free</dealloc>\n"
" </memory>\n"
"</def>";
const char xmldata2[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata2[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <memory>\n"
" <alloc>foo</alloc>\n"
@ -700,7 +700,7 @@ private:
ASSERT_EQUALS(library.deallocId("free"), library.allocId("foo"));
}
void memory3() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <memory>\n"
" <alloc arg=\"5\" init=\"false\">CreateX</alloc>\n"
@ -719,7 +719,7 @@ private:
}
void resource() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <resource>\n"
" <alloc>CreateX</alloc>\n"
@ -737,7 +737,7 @@ private:
void podtype() const {
{
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <podtype name=\"s8\" sign=\"s\" size=\"1\"/>\n"
" <podtype name=\"u8\" sign=\"u\" size=\"1\"/>\n"
@ -791,7 +791,7 @@ private:
}
void container() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <container id=\"A\" startPattern=\"std :: A &lt;\" endPattern=\"&gt; !!::\" itEndPattern=\"&gt; :: iterator\">\n"
" <type templateParameter=\"1\"/>\n"
@ -936,21 +936,21 @@ private:
void version() const {
{
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
"</def>";
Library library;
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
}
{
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def format=\"1\">\n"
"</def>";
Library library;
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
}
{
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def format=\"42\">\n"
"</def>";
Library library;

View File

@ -355,12 +355,12 @@ private:
// min/max and out-of-bounds - hex
{
const MathLib::bigint i = 0xFFFFFFFFFFFFFFFF;
constexpr MathLib::bigint i = 0xFFFFFFFFFFFFFFFF;
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
ASSERT_EQUALS(i, MathLib::toBigNumber("0xFFFFFFFFFFFFFFFF"));
}
{
const MathLib::bigint i = -0xFFFFFFFFFFFFFFFF;
constexpr MathLib::bigint i = -0xFFFFFFFFFFFFFFFF;
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
ASSERT_EQUALS(i, MathLib::toBigNumber("-0xFFFFFFFFFFFFFFFF"));
}
@ -370,12 +370,12 @@ private:
// min/max and out-of-bounds - octal
{
const MathLib::bigint i = 01777777777777777777777;
constexpr MathLib::bigint i = 01777777777777777777777;
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
ASSERT_EQUALS(i, MathLib::toBigNumber("01777777777777777777777"));
}
{
const MathLib::bigint i = -01777777777777777777777;
constexpr MathLib::bigint i = -01777777777777777777777;
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
ASSERT_EQUALS(i, MathLib::toBigNumber("-01777777777777777777777"));
}
@ -387,12 +387,12 @@ private:
SUPPRESS_WARNING_CLANG_PUSH("-Wimplicitly-unsigned-literal")
SUPPRESS_WARNING_GCC_PUSH("-Woverflow")
{
const MathLib::bigint i = 18446744073709551615;
constexpr MathLib::bigint i = 18446744073709551615;
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
ASSERT_EQUALS(i, MathLib::toBigNumber("18446744073709551615"));
}
{
const MathLib::bigint i = -18446744073709551615;
constexpr MathLib::bigint i = -18446744073709551615;
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
ASSERT_EQUALS(i, MathLib::toBigNumber("-18446744073709551615"));
}
@ -520,12 +520,12 @@ private:
// min/max and out-of-bounds - hex
{
const MathLib::biguint u = 0xFFFFFFFFFFFFFFFF;
constexpr MathLib::biguint u = 0xFFFFFFFFFFFFFFFF;
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
ASSERT_EQUALS(u, MathLib::toBigUNumber("0xFFFFFFFFFFFFFFFF"));
}
{
const MathLib::biguint u = -0xFFFFFFFFFFFFFFFF;
constexpr MathLib::biguint u = -0xFFFFFFFFFFFFFFFF;
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
ASSERT_EQUALS(u, MathLib::toBigUNumber("-0xFFFFFFFFFFFFFFFF"));
}
@ -535,12 +535,12 @@ private:
// min/max and out-of-bounds - octal
{
const MathLib::biguint u = 01777777777777777777777;
constexpr MathLib::biguint u = 01777777777777777777777;
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
ASSERT_EQUALS(u, MathLib::toBigUNumber("01777777777777777777777"));
}
{
const MathLib::biguint u = -01777777777777777777777;
constexpr MathLib::biguint u = -01777777777777777777777;
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
ASSERT_EQUALS(u, MathLib::toBigUNumber("-01777777777777777777777"));
}
@ -552,12 +552,12 @@ private:
SUPPRESS_WARNING_CLANG_PUSH("-Wimplicitly-unsigned-literal")
SUPPRESS_WARNING_GCC_PUSH("-Woverflow")
{
const MathLib::biguint u = 18446744073709551615;
constexpr MathLib::biguint u = 18446744073709551615;
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
ASSERT_EQUALS(u, MathLib::toBigUNumber("18446744073709551615"));
}
{
const MathLib::biguint u = -18446744073709551615;
constexpr MathLib::biguint u = -18446744073709551615;
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
ASSERT_EQUALS(u, MathLib::toBigUNumber("-18446744073709551615"));
}

View File

@ -4702,7 +4702,7 @@ private:
"}", nullptr, false, false);
ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str());
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"exit\">\n"
" <noreturn>true</noreturn>\n"
@ -6391,7 +6391,7 @@ private:
}
void duplicateExpression3() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"mystrcmp\">\n"
" <pure/>\n"

View File

@ -55,7 +55,7 @@ private:
void empty() const {
// An empty platform file does not change values, only the type.
const char xmldata[] = "<?xml version=\"1.0\"?>\n<platform/>";
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n<platform/>";
Platform platform;
// TODO: this should fail - platform files need to be complete
TODO_ASSERT(!readPlatform(platform, xmldata));
@ -189,7 +189,7 @@ private:
void valid_config_file_1() const {
// Valid platform configuration with all possible values specified.
// Similar to the avr8 platform file.
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<platform>\n"
" <char_bit>8</char_bit>\n"
" <default-sign>unsigned</default-sign>\n"
@ -233,7 +233,7 @@ private:
void valid_config_file_2() const {
// Valid platform configuration with all possible values specified and
// char_bit > 8.
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<platform>\n"
" <char_bit>20</char_bit>\n"
" <default-sign>signed</default-sign>\n"
@ -277,7 +277,7 @@ private:
void valid_config_file_3() const {
// Valid platform configuration without any usable information.
// Similar like an empty file.
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<platform>\n"
" <char_bit1>8</char_bit1>\n"
" <default-sign1>unsigned</default-sign1>\n"
@ -303,7 +303,7 @@ private:
void valid_config_file_4() const {
// Valid platform configuration with all possible values specified and
// set to 0.
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<platform>\n"
" <char_bit>0</char_bit>\n"
" <default-sign>z</default-sign>\n"
@ -346,7 +346,7 @@ private:
void invalid_config_file_1() const {
// Invalid XML file: mismatching elements "boolt" vs "bool".
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<platform>\n"
" <char_bit>8</char_bit>\n"
" <default-sign>unsigned</default-sign>\n"
@ -371,7 +371,7 @@ private:
void empty_elements() const {
// Valid platform configuration without any usable information.
// Similar like an empty file.
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<platform>\n"
" <char_bit></char_bit>\n"
" <default-sign></default-sign>\n"

View File

@ -289,9 +289,9 @@ private:
return;
#ifdef _WIN32
const char exe[] = "clang-tidy.exe";
constexpr char exe[] = "clang-tidy.exe";
#else
const char exe[] = "clang-tidy";
constexpr char exe[] = "clang-tidy";
#endif
(void)exe;

View File

@ -276,9 +276,9 @@ private:
return;
#ifdef _WIN32
const char exe[] = "clang-tidy.exe";
constexpr char exe[] = "clang-tidy.exe";
#else
const char exe[] = "clang-tidy";
constexpr char exe[] = "clang-tidy";
#endif
const std::string file = fprefix() + "_001.cpp";

View File

@ -6167,7 +6167,7 @@ private:
ASSERT(db);
const Scope * bar = db->findScopeByName("bar");
ASSERT(bar != nullptr);
const unsigned int linenrs[2] = { 2, 1 };
constexpr unsigned int linenrs[2] = { 2, 1 };
unsigned int index = 0;
for (const Token * tok = bar->bodyStart->next(); tok != bar->bodyEnd; tok = tok->next()) {
if (Token::Match(tok, "%name% (") && !tok->varId() && Token::simpleMatch(tok->linkAt(1), ") ;")) {
@ -8520,9 +8520,9 @@ private:
{
// Char types
Settings settings;
const Library::PodType char8 = { 1, 'u' };
const Library::PodType char16 = { 2, 'u' };
const Library::PodType char32 = { 4, 'u' };
constexpr Library::PodType char8 = { 1, 'u' };
constexpr Library::PodType char16 = { 2, 'u' };
constexpr Library::PodType char32 = { 4, 'u' };
settings.library.mPodTypes["char8_t"] = char8;
settings.library.mPodTypes["char16_t"] = char16;
settings.library.mPodTypes["char32_t"] = char32;
@ -8539,8 +8539,8 @@ private:
{
// PodType
Settings settingsWin64 = settingsBuilder().platform(Platform::Type::Win64).build();
const Library::PodType u32 = { 4, 'u' };
const Library::PodType podtype2 = { 0, 'u', Library::PodType::Type::INT };
constexpr Library::PodType u32 = { 4, 'u' };
constexpr Library::PodType podtype2 = { 0, 'u', Library::PodType::Type::INT };
settingsWin64.library.mPodTypes["u32"] = u32;
settingsWin64.library.mPodTypes["xyz::x"] = u32;
settingsWin64.library.mPodTypes["podtype2"] = podtype2;

View File

@ -288,9 +288,9 @@ private:
return;
#ifdef _WIN32
const char exe[] = "clang-tidy.exe";
constexpr char exe[] = "clang-tidy.exe";
#else
const char exe[] = "clang-tidy";
constexpr char exe[] = "clang-tidy";
#endif
const std::string file = fprefix() + "_1.cpp";

View File

@ -833,7 +833,7 @@ private:
{
// Ticket #6701 - Variable name is a POD type according to cfg
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def format=\"1\">"
" <podtype name=\"_tm\"/>"
"</def>";
@ -4470,7 +4470,7 @@ private:
ASSERT_EQUALS("", errout.str());
{
const char argDirectionsTestXmlData[] = "<?xml version=\"1.0\"?>\n"
constexpr char argDirectionsTestXmlData[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"uninitvar_funcArgInTest\">\n"
" <arg nr=\"1\" direction=\"in\"/>\n"

View File

@ -5354,7 +5354,7 @@ private:
}
void localvarOp() {
const char op[] = "+-*/%&|^";
constexpr char op[] = "+-*/%&|^";
for (const char *p = op; *p; ++p) {
std::string code("int main()\n"
"{\n"

View File

@ -46,7 +46,7 @@ private:
void run() override {
// strcpy, abort cfg
const char cfg[] = "<?xml version=\"1.0\"?>\n"
constexpr char cfg[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"strcpy\"> <arg nr=\"1\"><not-null/></arg> </function>\n"
" <function name=\"abort\"> <noreturn>true</noreturn> </function>\n" // abort is a noreturn function

View File

@ -431,7 +431,7 @@ int main(int argc, char **argv)
}
}
static const char makefile[] = "Makefile";
static constexpr char makefile[] = "Makefile";
std::ofstream fout(makefile, std::ios_base::trunc);
if (!fout.is_open()) {
std::cerr << "An error occurred while trying to open "

View File

@ -64,7 +64,7 @@ class QWidget;
const QString WORK_FOLDER(QDir::homePath() + "/triage");
const QString DACA2_PACKAGES(QDir::homePath() + "/daca2-packages");
const int MAX_ERRORS = 100;
constexpr int MAX_ERRORS = 100;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),