aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-09-22 00:26:19 +0800
committerErik Kundt <bitshift@posteo.org>2018-09-22 00:44:56 +0800
commitff5be1799088ca51fb51e9c86031bd2d88fe3bce (patch)
tree3ce2d2042576e7a96d33ce73f81411ee66f9e9ac /libsolidity/analysis
parent5f919d02abc21e17d533a18876eabdf1a91939f7 (diff)
downloaddexon-solidity-ff5be1799088ca51fb51e9c86031bd2d88fe3bce.tar.gz
dexon-solidity-ff5be1799088ca51fb51e9c86031bd2d88fe3bce.tar.zst
dexon-solidity-ff5be1799088ca51fb51e9c86031bd2d88fe3bce.zip
Disallows fixed-size multidim. arrays with zero-length.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 3056561b..3b5e7b11 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -822,12 +822,17 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
{
case Type::Category::Array:
if (auto arrayType = dynamic_cast<ArrayType const*>(varType.get()))
+ {
if (
((arrayType->location() == DataLocation::Memory) ||
(arrayType->location() == DataLocation::CallData)) &&
!arrayType->validForCalldata()
)
m_errorReporter.typeError(_variable.location(), "Array is too large to be encoded.");
+ if (auto baseType = dynamic_cast<ArrayType const*>(arrayType->baseType().get()))
+ if (!baseType->isDynamicallySized() && baseType->length() == 0)
+ m_errorReporter.typeError(_variable.location(), "Fixed-size multidimensional arrays are not allowed to have zero length.");
+ }
break;
case Type::Category::Mapping:
if (auto mappingType = dynamic_cast<MappingType const*>(varType.get()))