diff options
author | chriseth <c@ethdev.com> | 2017-01-21 02:21:43 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-01-21 02:22:39 +0800 |
commit | 0ef460461ac280a9f8086d62d831dc9f7d2f5319 (patch) | |
tree | 8dd8f0b6007ed7979f5190bce87f1918a8c0f205 /libsolidity/analysis | |
parent | df4ef74199392e9b29823d68e6a58dabd490e037 (diff) | |
download | dexon-solidity-0ef460461ac280a9f8086d62d831dc9f7d2f5319.tar.gz dexon-solidity-0ef460461ac280a9f8086d62d831dc9f7d2f5319.tar.zst dexon-solidity-0ef460461ac280a9f8086d62d831dc9f7d2f5319.zip |
Check if constructor is public or not.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 67c8ac17..adb3d54f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -75,7 +75,10 @@ bool TypeChecker::visit(ContractDefinition const& _contract) checkContractAbstractConstructors(_contract); FunctionDefinition const* function = _contract.constructor(); - if (function) { + if (function) + { + if (!function->isPublic()) + _contract.annotation().hasPublicConstructor = false; if (!function->returnParameters().empty()) typeError(function->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor."); if (function->isDeclaredConst()) @@ -1280,6 +1283,8 @@ void TypeChecker::endVisit(NewExpression const& _newExpression) fatalTypeError(_newExpression.location(), "Identifier is not a contract."); if (!contract->annotation().isFullyImplemented) typeError(_newExpression.location(), "Trying to create an instance of an abstract contract."); + if (!contract->annotation().hasPublicConstructor) + typeError(_newExpression.location(), "Contract with internal constructor cannot be created directly."); solAssert(!!m_scope, ""); m_scope->annotation().contractDependencies.insert(contract); |