aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2019-01-15 07:14:10 +0800
committerchriseth <chris@ethereum.org>2019-01-18 03:36:48 +0800
commit0bfdaa500af6ae1a480f6f6f417a6a12ada0a313 (patch)
tree309a529d0c9d785d4062d77822ab3df1548224d3 /libsolidity/analysis
parente6fee257e68e7b145a47eee8c5937db7a7a99849 (diff)
downloaddexon-solidity-0bfdaa500af6ae1a480f6f6f417a6a12ada0a313.tar.gz
dexon-solidity-0bfdaa500af6ae1a480f6f6f417a6a12ada0a313.tar.zst
dexon-solidity-0bfdaa500af6ae1a480f6f6f417a6a12ada0a313.zip
Add code access dependency.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 4cdfcc0c..ee5865f7 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2100,9 +2100,20 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
{
if (magicType->kind() == MagicType::Kind::ABI)
annotation.isPure = true;
- else if (magicType->kind() == MagicType::Kind::MetaType)
- if (memberName == "creationCode" || memberName == "runtimeCode")
- annotation.isPure = true;
+ else if (magicType->kind() == MagicType::Kind::MetaType && (
+ memberName == "creationCode" || memberName == "runtimeCode"
+ ))
+ {
+ annotation.isPure = true;
+ m_scope->annotation().contractDependencies.insert(
+ &dynamic_cast<ContractType const&>(*magicType->typeArgument()).contractDefinition()
+ );
+ if (contractDependenciesAreCyclic(*m_scope))
+ m_errorReporter.typeError(
+ _memberAccess.location(),
+ "Circular reference for contract code access."
+ );
+ }
}
return false;