aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ContractLevelChecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/analysis/ContractLevelChecker.cpp')
-rw-r--r--libsolidity/analysis/ContractLevelChecker.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp
index 0ddb198f..879903de 100644
--- a/libsolidity/analysis/ContractLevelChecker.cpp
+++ b/libsolidity/analysis/ContractLevelChecker.cpp
@@ -40,6 +40,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract)
checkIllegalOverrides(_contract);
checkAbstractFunctions(_contract);
checkBaseConstructorArguments(_contract);
+ checkConstructor(_contract);
return Error::containsOnlyWarnings(m_errorReporter.errors());
}
@@ -339,3 +340,22 @@ void ContractLevelChecker::annotateBaseConstructorArguments(
}
}
+
+void ContractLevelChecker::checkConstructor(ContractDefinition const& _contract)
+{
+ FunctionDefinition const* constructor = _contract.constructor();
+ if (!constructor)
+ return;
+
+ if (!constructor->returnParameters().empty())
+ m_errorReporter.typeError(constructor->returnParameterList()->location(), "Non-empty \"returns\" directive for constructor.");
+ if (constructor->stateMutability() != StateMutability::NonPayable && constructor->stateMutability() != StateMutability::Payable)
+ m_errorReporter.typeError(
+ constructor->location(),
+ "Constructor must be payable or non-payable, but is \"" +
+ stateMutabilityToString(constructor->stateMutability()) +
+ "\"."
+ );
+ if (constructor->visibility() != FunctionDefinition::Visibility::Public && constructor->visibility() != FunctionDefinition::Visibility::Internal)
+ m_errorReporter.typeError(constructor->location(), "Constructor must be public or internal.");
+}