mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adding fixes for signedness warnings in libsolidity
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
co-authored by
Kamil Śliwak
parent
0a5d99279d
commit
c6e4943089
@@ -38,7 +38,7 @@ using namespace solidity;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
ASTNode::ASTNode(int64_t _id, SourceLocation _location):
|
||||
m_id(_id),
|
||||
m_id(static_cast<size_t>(_id)),
|
||||
m_location(std::move(_location))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
virtual ~ASTNode() {}
|
||||
|
||||
/// @returns an identifier of this AST node that is unique for a single compilation run.
|
||||
int64_t id() const { return m_id; }
|
||||
int64_t id() const { return int64_t(m_id); }
|
||||
|
||||
virtual void accept(ASTVisitor& _visitor) = 0;
|
||||
virtual void accept(ASTConstVisitor& _visitor) const = 0;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
@@ -134,7 +135,7 @@ size_t ASTJsonConverter::sourceIndexFromLocation(SourceLocation const& _location
|
||||
if (_location.source && m_sourceIndices.count(_location.source->name()))
|
||||
return m_sourceIndices.at(_location.source->name());
|
||||
else
|
||||
return size_t(-1);
|
||||
return numeric_limits<size_t>::max();
|
||||
}
|
||||
|
||||
string ASTJsonConverter::sourceLocationToString(SourceLocation const& _location) const
|
||||
|
||||
@@ -92,7 +92,7 @@ SourceLocation const ASTJsonImporter::createSourceLocation(Json::Value const& _n
|
||||
{
|
||||
astAssert(member(_node, "src").isString(), "'src' must be a string");
|
||||
|
||||
return solidity::langutil::parseSourceLocation(_node["src"].asString(), m_currentSourceName, int(m_sourceLocations.size()));
|
||||
return solidity::langutil::parseSourceLocation(_node["src"].asString(), m_currentSourceName, m_sourceLocations.size());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -773,7 +773,7 @@ tuple<bool, rational> RationalNumberType::parseRational(string const& _value)
|
||||
denominator = bigint(string(fractionalBegin, _value.end()));
|
||||
denominator /= boost::multiprecision::pow(
|
||||
bigint(10),
|
||||
distance(radixPoint + 1, _value.end())
|
||||
static_cast<size_t>(distance(radixPoint + 1, _value.end()))
|
||||
);
|
||||
numerator = bigint(string(_value.begin(), radixPoint));
|
||||
value = numerator + denominator;
|
||||
@@ -1065,7 +1065,7 @@ TypeResult RationalNumberType::binaryOperatorResult(Token _operator, Type const*
|
||||
if (_base == 1)
|
||||
return 1;
|
||||
else if (_base == -1)
|
||||
return 1 - 2 * int(_exponent & 1);
|
||||
return 1 - 2 * static_cast<int>(_exponent & 1);
|
||||
else
|
||||
return boost::multiprecision::pow(_base, _exponent);
|
||||
};
|
||||
@@ -1171,7 +1171,7 @@ string RationalNumberType::bigintToReadableString(bigint const& _num)
|
||||
string str = _num.str();
|
||||
if (str.size() > 32)
|
||||
{
|
||||
int omitted = str.size() - 8;
|
||||
size_t omitted = str.size() - 8;
|
||||
str = str.substr(0, 4) + "...(" + to_string(omitted) + " digits omitted)..." + str.substr(str.size() - 4, 4);
|
||||
}
|
||||
return str;
|
||||
@@ -1201,7 +1201,7 @@ u256 RationalNumberType::literalValue(Literal const*) const
|
||||
{
|
||||
auto fixed = fixedPointType();
|
||||
solAssert(fixed, "Rational number cannot be represented as fixed point type.");
|
||||
int fractionalDigits = fixed->fractionalDigits();
|
||||
unsigned fractionalDigits = fixed->fractionalDigits();
|
||||
shiftedValue = m_value.numerator() * boost::multiprecision::pow(bigint(10), fractionalDigits) / m_value.denominator();
|
||||
}
|
||||
|
||||
@@ -1291,7 +1291,7 @@ StringLiteralType::StringLiteralType(string _value):
|
||||
BoolResult StringLiteralType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
{
|
||||
if (auto fixedBytes = dynamic_cast<FixedBytesType const*>(&_convertTo))
|
||||
return size_t(fixedBytes->numBytes()) >= m_value.size();
|
||||
return static_cast<size_t>(fixedBytes->numBytes()) >= m_value.size();
|
||||
else if (auto arrayType = dynamic_cast<ArrayType const*>(&_convertTo))
|
||||
return
|
||||
arrayType->isByteArray() &&
|
||||
|
||||
Reference in New Issue
Block a user