diff options
author | chriseth <chris@ethereum.org> | 2018-11-30 01:36:26 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-11-30 23:30:20 +0800 |
commit | 33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a (patch) | |
tree | 310438d5e1cc0aceb60ed07c9a9a9428787dff45 /libsolidity/analysis/ContractLevelChecker.cpp | |
parent | 4f992298c6381b3c7ea41462bce749850b5846e5 (diff) | |
download | dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.tar dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.tar.gz dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.tar.bz2 dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.tar.lz dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.tar.xz dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.tar.zst dexon-solidity-33d6a24c47f4cfd95e8bb880d5254fb7dd6ea21a.zip |
Move library related checks.
Diffstat (limited to 'libsolidity/analysis/ContractLevelChecker.cpp')
-rw-r--r-- | libsolidity/analysis/ContractLevelChecker.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index 419ebe93..58dcfe4d 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -44,6 +44,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract) checkFallbackFunction(_contract); checkExternalTypeClashes(_contract); checkHashCollisions(_contract); + checkLibraryRequirements(_contract); return Error::containsOnlyWarnings(m_errorReporter.errors()); } @@ -436,3 +437,16 @@ void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contra hashes.insert(hash); } } + +void ContractLevelChecker::checkLibraryRequirements(ContractDefinition const& _contract) +{ + if (!_contract.isLibrary()) + return; + + if (!_contract.baseContracts().empty()) + m_errorReporter.typeError(_contract.location(), "Library is not allowed to inherit."); + + for (auto const& var: _contract.stateVariables()) + if (!var->isConstant()) + m_errorReporter.typeError(var->location(), "Library cannot have non-constant state variables"); +} |