mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9096 from ethereum/conversionWarningsLibSol
Adding fixes for signedness warnings in libsolidity
This commit is contained in:
@@ -606,7 +606,7 @@ BOOST_AUTO_TEST_CASE(bytesNN_arrays)
|
||||
BOTH_ENCODERS(
|
||||
for (size_t size = 1; size < 15; size++)
|
||||
{
|
||||
for (size_t width: {1, 2, 4, 5, 7, 15, 16, 17, 31, 32})
|
||||
for (size_t width: {1u, 2u, 4u, 5u, 7u, 15u, 16u, 17u, 31u, 32u})
|
||||
{
|
||||
string source = boost::algorithm::replace_all_copy(sourceCode, "SIZE", to_string(size));
|
||||
source = boost::algorithm::replace_all_copy(source, "UINTWIDTH", to_string(width * 8));
|
||||
@@ -651,7 +651,7 @@ BOOST_AUTO_TEST_CASE(bytesNN_arrays_dyn)
|
||||
BOTH_ENCODERS(
|
||||
for (size_t size = 0; size < 15; size++)
|
||||
{
|
||||
for (size_t width: {1, 2, 4, 5, 7, 15, 16, 17, 31, 32})
|
||||
for (size_t width: {1u, 2u, 4u, 5u, 7u, 15u, 16u, 17u, 31u, 32u})
|
||||
{
|
||||
string source = boost::algorithm::replace_all_copy(sourceCode, "SIZE", to_string(size));
|
||||
source = boost::algorithm::replace_all_copy(source, "UINTWIDTH", to_string(width * 8));
|
||||
|
||||
@@ -116,21 +116,21 @@ TestCase::TestResult SMTCheckerJSONTest::run(ostream& _stream, string const& _li
|
||||
!location["end"].isInt()
|
||||
)
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Error must have a SourceLocation with start and end."));
|
||||
int start = location["start"].asInt();
|
||||
int end = location["end"].asInt();
|
||||
size_t start = location["start"].asUInt();
|
||||
size_t end = location["end"].asUInt();
|
||||
std::string sourceName;
|
||||
if (location.isMember("source") && location["source"].isString())
|
||||
sourceName = location["source"].asString();
|
||||
if (start >= static_cast<int>(preamble.size()))
|
||||
if (start >= preamble.size())
|
||||
start -= preamble.size();
|
||||
if (end >= static_cast<int>(preamble.size()))
|
||||
if (end >= preamble.size())
|
||||
end -= preamble.size();
|
||||
m_errorList.emplace_back(SyntaxTestError{
|
||||
error["type"].asString(),
|
||||
error["message"].asString(),
|
||||
sourceName,
|
||||
start,
|
||||
end
|
||||
static_cast<int>(start),
|
||||
static_cast<int>(end)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ bytes compileFirstExpression(
|
||||
);
|
||||
context.resetVisitedNodes(contract);
|
||||
context.setMostDerivedContract(*contract);
|
||||
unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack
|
||||
context.adjustStackOffset(parametersSize);
|
||||
size_t parametersSize = _localVariables.size(); // assume they are all one slot on the stack
|
||||
context.adjustStackOffset(static_cast<int>(parametersSize));
|
||||
for (vector<string> const& variable: _localVariables)
|
||||
context.addVariable(
|
||||
dynamic_cast<VariableDeclaration const&>(resolveDeclaration(*sourceUnit, variable, resolver)),
|
||||
|
||||
@@ -491,7 +491,7 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
|
||||
#endif
|
||||
#endif
|
||||
#if __SANITIZE_ADDRESS__
|
||||
maxDuration = size_t(-1);
|
||||
maxDuration = numeric_limits<size_t>::max();
|
||||
BOOST_TEST_MESSAGE("Disabled constant optimizer run time check for address sanitizer build.");
|
||||
#endif
|
||||
BOOST_CHECK_MESSAGE(duration <= maxDuration, "Compilation of constants took longer than 20 seconds.");
|
||||
|
||||
@@ -675,7 +675,7 @@ BOOST_AUTO_TEST_CASE(inline_asm_end_location)
|
||||
bool visit(InlineAssembly const& _inlineAsm) override
|
||||
{
|
||||
auto loc = _inlineAsm.location();
|
||||
auto asmStr = loc.source->source().substr(loc.start, loc.end - loc.start);
|
||||
auto asmStr = loc.source->source().substr(static_cast<size_t>(loc.start), static_cast<size_t>(loc.end - loc.start));
|
||||
BOOST_CHECK_EQUAL(asmStr, "assembly { a := 0x12345678 }");
|
||||
visited = true;
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ void SyntaxTest::filterObtainedErrors()
|
||||
{
|
||||
// ignore the version & license pragma inserted by the testing tool when calculating locations.
|
||||
if (location->start >= static_cast<int>(preamble.size()))
|
||||
locationStart = location->start - (preamble.size());
|
||||
locationStart = location->start - static_cast<int>(preamble.size());
|
||||
if (location->end >= static_cast<int>(preamble.size()))
|
||||
locationEnd = location->end - (preamble.size());
|
||||
locationEnd = location->end - static_cast<int>(preamble.size());
|
||||
if (location->source)
|
||||
sourceName = location->source->name();
|
||||
}
|
||||
|
||||
@@ -348,10 +348,10 @@ string BytesUtils::formatBytesRange(
|
||||
|
||||
size_t BytesUtils::countRightPaddedZeros(bytes const& _bytes)
|
||||
{
|
||||
return find_if(
|
||||
return static_cast<size_t>(find_if(
|
||||
_bytes.rbegin(),
|
||||
_bytes.rend(),
|
||||
[](uint8_t b) { return b != '\0'; }
|
||||
) - _bytes.rbegin();
|
||||
) - _bytes.rbegin());
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ void testFunctionCall(
|
||||
ABI_CHECK(_call.expectations.rawBytes(), _expectations);
|
||||
BOOST_REQUIRE_EQUAL(_call.displayMode, _mode);
|
||||
BOOST_REQUIRE_EQUAL(_call.value.value, _value.value);
|
||||
BOOST_REQUIRE_EQUAL(size_t(_call.value.unit), size_t(_value.unit));
|
||||
BOOST_REQUIRE_EQUAL(static_cast<size_t>(_call.value.unit), static_cast<size_t>(_value.unit));
|
||||
BOOST_REQUIRE_EQUAL(_call.arguments.comment, _argumentComment);
|
||||
BOOST_REQUIRE_EQUAL(_call.expectations.comment, _expectationComment);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user