Adding fixes for signedness warnings in libsolidity

Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
Djordje Mijovic
2020-06-10 10:41:55 +02:00
co-authored by Kamil Śliwak
parent 0a5d99279d
commit c6e4943089
32 changed files with 145 additions and 138 deletions
+17 -17
View File
@@ -666,7 +666,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
{
auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier);
if (ref == _inlineAssembly.annotation().externalReferences.end())
return size_t(-1);
return numeric_limits<size_t>::max();
Declaration const* declaration = ref->second.declaration;
solAssert(!!declaration, "");
bool requiresStorage = ref->second.isSlot || ref->second.isOffset;
@@ -676,7 +676,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (var->immutable())
{
m_errorReporter.typeError(3773_error, _identifier.location, "Assembly access to immutable variables is not supported.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
if (var->isConstant())
{
@@ -685,17 +685,17 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (var && !var->value())
{
m_errorReporter.typeError(3224_error, _identifier.location, "Constant has no value.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (_context == yul::IdentifierContext::LValue)
{
m_errorReporter.typeError(6252_error, _identifier.location, "Constant variables cannot be assigned to.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (requiresStorage)
{
m_errorReporter.typeError(6617_error, _identifier.location, "The suffixes _offset and _slot can only be used on non-constant storage variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (var && var->value() && !var->value()->annotation().type && !dynamic_cast<Literal const*>(var->value().get()))
{
@@ -723,19 +723,19 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (!var->isStateVariable() && !var->type()->dataStoredIn(DataLocation::Storage))
{
m_errorReporter.typeError(3622_error, _identifier.location, "The suffixes _offset and _slot can only be used on storage variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (_context == yul::IdentifierContext::LValue)
{
if (var->isStateVariable())
{
m_errorReporter.typeError(4713_error, _identifier.location, "State variables cannot be assigned to - you have to use \"sstore()\".");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (ref->second.isOffset)
{
m_errorReporter.typeError(9739_error, _identifier.location, "Only _slot can be assigned to.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else
solAssert(ref->second.isSlot, "");
@@ -744,12 +744,12 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
else if (!var->isConstant() && var->isStateVariable())
{
m_errorReporter.typeError(1408_error, _identifier.location, "Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (var->type()->dataStoredIn(DataLocation::Storage))
{
m_errorReporter.typeError(9068_error, _identifier.location, "You have to use the _slot or _offset suffix to access storage reference variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (var->type()->sizeOnStack() != 1)
{
@@ -757,21 +757,21 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
m_errorReporter.typeError(2370_error, _identifier.location, "Call data elements cannot be accessed directly. Copy to a local variable first or use \"calldataload\" or \"calldatacopy\" with manually determined offsets and sizes.");
else
m_errorReporter.typeError(9857_error, _identifier.location, "Only types that use one stack slot are supported.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
}
else if (requiresStorage)
{
m_errorReporter.typeError(7944_error, _identifier.location, "The suffixes _offset and _slot can only be used on storage variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (_context == yul::IdentifierContext::LValue)
{
if (dynamic_cast<MagicVariableDeclaration const*>(declaration))
return size_t(-1);
return numeric_limits<size_t>::max();
m_errorReporter.typeError(1990_error, _identifier.location, "Only local variables can be assigned to in inline assembly.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
if (_context == yul::IdentifierContext::RValue)
@@ -780,7 +780,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (dynamic_cast<FunctionDefinition const*>(declaration))
{
m_errorReporter.declarationError(2025_error, _identifier.location, "Access to functions is not allowed in inline assembly.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (dynamic_cast<VariableDeclaration const*>(declaration))
{
@@ -790,11 +790,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (!contract->isLibrary())
{
m_errorReporter.typeError(4977_error, _identifier.location, "Expected a library.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
}
else
return size_t(-1);
return numeric_limits<size_t>::max();
}
ref->second.valueSize = 1;
return size_t(1);