Move collision warnings to StaticAnalyzer

This commit is contained in:
a3d4 2020-09-14 02:52:00 +02:00
parent e7a6534d4f
commit d8520b0af0
4 changed files with 14 additions and 17 deletions

View File

@ -156,6 +156,20 @@ bool StaticAnalyzer::visit(VariableDeclaration const& _variable)
// This is not a no-op, the entry might pre-exist. // This is not a no-op, the entry might pre-exist.
m_localVarUseCount[make_pair(_variable.id(), &_variable)] += 0; m_localVarUseCount[make_pair(_variable.id(), &_variable)] += 0;
} }
if (_variable.isStateVariable() || _variable.referenceLocation() == VariableDeclaration::Location::Storage)
{
TypePointer varType = _variable.annotation().type;
for (Type const* subtype: frontend::oversizedSubtypes(*varType))
{
string message = "Type " + subtype->toString(true) +
" covers a large part of storage and thus makes collisions likely."
" Either use mappings or dynamic arrays and allow their size to be increased only"
" in small quantities per transaction.";
m_errorReporter.warning(7325_error, _variable.typeName().location(), message);
}
}
return true; return true;
} }

View File

@ -609,19 +609,6 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
} }
} }
if (varType->dataStoredIn(DataLocation::Storage))
{
vector<Type const*> oversizedSubtypes = frontend::oversizedSubtypes(*varType);
for (Type const* subtype: oversizedSubtypes)
{
string message = "Type " + subtype->toString(true) +
" covers a large part of storage and thus makes collisions likely."
" Either use mappings or dynamic arrays and allow their size to be increased only"
" in small quantities per transaction.";
m_errorReporter.warning(7325_error, _variable.typeName().location(), message);
}
}
return false; return false;
} }

View File

@ -6,5 +6,3 @@ contract C {
} }
// ---- // ----
// TypeError 7676: (60-114): Contract too large for storage. // TypeError 7676: (60-114): Contract too large for storage.
// Warning 7325: (77-89): Type uint256[57896044618658097711785492504343953926634992332820282019728792003956564819968] covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
// Warning 7325: (97-109): Type uint256[57896044618658097711785492504343953926634992332820282019728792003956564819968] covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.

View File

@ -8,5 +8,3 @@ contract D is C {
} }
// ---- // ----
// TypeError 7676: (95-134): Contract too large for storage. // TypeError 7676: (95-134): Contract too large for storage.
// Warning 7325: (77-89): Type uint256[57896044618658097711785492504343953926634992332820282019728792003956564819968] covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
// Warning 7325: (117-129): Type uint256[57896044618658097711785492504343953926634992332820282019728792003956564819968] covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.