Skip to content

Commit 6e55812

Browse files
authored
fixed some compiler errors with USE_BOOST_INT128 (#7833)
1 parent e89d6a6 commit 6e55812

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ ValueFlow::Value CheckBufferOverrun::getBufferSize(const Token *bufTok) const
564564
if (!var || var->isPointer())
565565
return ValueFlow::Value(-1);
566566

567-
const MathLib::bigint dim = std::accumulate(var->dimensions().cbegin(), var->dimensions().cend(), 1LL, [](MathLib::bigint i1, const Dimension &dim) {
567+
const MathLib::bigint dim = std::accumulate(var->dimensions().cbegin(), var->dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint i1, const Dimension &dim) {
568568
return i1 * dim.num;
569569
});
570570

lib/checktype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ void CheckType::checkFloatToIntegerOverflow(const Token *tok, const ValueType *v
511511
bits = mSettings->platform.long_long_bit;
512512
else
513513
continue;
514-
if (bits < MathLib::bigint_bits && f.floatValue >= (static_cast<MathLib::biguint>(1) << bits))
514+
if (bits < MathLib::bigint_bits && f.floatValue >= (1ULL << bits))
515515
floatToIntegerOverflowError(tok, f);
516516
}
517517
}

lib/clangimport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
785785
if (nodeType == BreakStmt)
786786
return addtoken(tokenList, "break");
787787
if (nodeType == CharacterLiteral) {
788-
const int c = MathLib::toBigNumber(mExtTokens.back());
788+
const int c = static_cast<int>(MathLib::toBigNumber(mExtTokens.back()));
789789
if (c == 0)
790790
return addtoken(tokenList, "\'\\0\'");
791791
if (c == '\r')
@@ -1582,7 +1582,7 @@ static void setValues(const Tokenizer &tokenizer, const SymbolDatabase *symbolDa
15821582

15831583
MathLib::bigint typeSize = 0;
15841584
for (const Variable &var: scope.varlist) {
1585-
const int mul = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), 1, [](int v, const Dimension& dim) {
1585+
const MathLib::bigint mul = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint v, const Dimension& dim) {
15861586
return v * dim.num;
15871587
});
15881588
if (var.valueType())

lib/token.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,10 @@ class CPPCHECKLIB Token {
778778
bool setBits(const MathLib::bigint b) {
779779
const MathLib::bigint max = std::numeric_limits<short>::max();
780780
if (b > max) {
781-
mImpl->mBits = max;
781+
mImpl->mBits = static_cast<short>(max);
782782
return false;
783783
}
784-
mImpl->mBits = b < 0 ? -1 : b;
784+
mImpl->mBits = b < 0 ? -1 : static_cast<short>(b);
785785
return true;
786786
}
787787

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10025,7 +10025,7 @@ void Tokenizer::simplifyBitfields()
1002510025
}
1002610026

1002710027
const auto tooLargeError = [this](const Token *tok) {
10028-
const MathLib::bigint max = std::numeric_limits<short>::max();
10028+
const auto max = std::numeric_limits<short>::max();
1002910029
reportError(tok,
1003010030
Severity::warning,
1003110031
"tooLargeBitField",

lib/valueflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static Result accumulateStructMembers(const Scope* scope, F f, ValueFlow::Accura
445445
if (const ValueType* vt = var.valueType()) {
446446
if (vt->type == ValueType::Type::RECORD && vt->typeScope == scope)
447447
return {0, false};
448-
const MathLib::bigint dim = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), 1LL, [](MathLib::bigint i1, const Dimension& dim) {
448+
const MathLib::bigint dim = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint i1, const Dimension& dim) {
449449
return i1 * dim.num;
450450
});
451451
if (var.nameToken()->scope() != scope && var.nameToken()->scope()->definedType) { // anonymous union

test/testclangimport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ class TestClangImport : public TestFixture {
12791279
ASSERT(!!tok);
12801280
tok = tok->next();
12811281
ASSERT(tok->hasKnownIntValue());
1282-
ASSERT_EQUALS(44, tok->getKnownIntValue());
1282+
ASSERT_EQUALS(MathLib::bigint(44), tok->getKnownIntValue());
12831283
}
12841284

12851285
void valueFlow2() {

0 commit comments

Comments
 (0)