aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-06 18:45:11 +0800
committerGitHub <noreply@github.com>2017-07-06 18:45:11 +0800
commit0fb4cb1ab9bb4b6cc72e28cc5a1753ad14781f14 (patch)
tree1031e61422e41884ecd548953f83ef4df9441f61 /libsolidity
parent194ff033ae44944ac59aa7bd3da89ba94ec5893c (diff)
parent40d4ee49528affa1e88031920a9be57375ad5788 (diff)
downloaddexon-solidity-0fb4cb1ab9bb4b6cc72e28cc5a1753ad14781f14.tar.gz
dexon-solidity-0fb4cb1ab9bb4b6cc72e28cc5a1753ad14781f14.tar.zst
dexon-solidity-0fb4cb1ab9bb4b6cc72e28cc5a1753ad14781f14.zip
Merge pull request #2532 from ethereum/develop
Merge develop to release for 0.4.13.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp15
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp10
-rw-r--r--libsolidity/analysis/SyntaxChecker.h3
-rw-r--r--libsolidity/analysis/TypeChecker.cpp10
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp3
-rw-r--r--libsolidity/interface/StandardCompiler.cpp12
6 files changed, 42 insertions, 11 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 2a5f27df..cc95c294 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -289,7 +289,20 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
typeLoc = DataLocation::Memory;
}
else if (varLoc == Location::Default)
- typeLoc = _variable.isCallableParameter() ? DataLocation::Memory : DataLocation::Storage;
+ {
+ if (_variable.isCallableParameter())
+ typeLoc = DataLocation::Memory;
+ else
+ {
+ typeLoc = DataLocation::Storage;
+ if (!_variable.isStateVariable())
+ m_errorReporter.warning(
+ _variable.location(),
+ "Variable is declared as a storage pointer. "
+ "Use an explicit \"storage\" keyword to silence this warning."
+ );
+ }
+ }
else
typeLoc = varLoc == Location::Memory ? DataLocation::Memory : DataLocation::Storage;
isPointer = !_variable.isStateVariable();
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 02e2fdcf..bde0e616 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -135,6 +135,16 @@ bool SyntaxChecker::visit(Break const& _breakStatement)
return true;
}
+bool SyntaxChecker::visit(Throw const& _throwStatement)
+{
+ m_errorReporter.warning(
+ _throwStatement.location(),
+ "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"."
+ );
+
+ return true;
+}
+
bool SyntaxChecker::visit(UnaryOperation const& _operation)
{
if (_operation.getOperator() == Token::Add)
diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h
index ec6ac434..fb5cc6d7 100644
--- a/libsolidity/analysis/SyntaxChecker.h
+++ b/libsolidity/analysis/SyntaxChecker.h
@@ -33,6 +33,7 @@ namespace solidity
* - whether continue/break is in a for/while loop.
* - whether a modifier contains at least one '_'
* - issues deprecation warnings for unary '+'
+ * - issues deprecation warning for throw
*/
class SyntaxChecker: private ASTConstVisitor
{
@@ -59,6 +60,8 @@ private:
virtual bool visit(Continue const& _continueStatement) override;
virtual bool visit(Break const& _breakStatement) override;
+ virtual bool visit(Throw const& _throwStatement) override;
+
virtual bool visit(UnaryOperation const& _operation) override;
virtual bool visit(PlaceholderStatement const& _placeholderStatement) override;
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 1563467c..7306a36d 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -854,10 +854,12 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
if (auto ref = dynamic_cast<ReferenceType const*>(type(varDecl).get()))
{
if (ref->dataStoredIn(DataLocation::Storage))
- m_errorReporter.warning(
- varDecl.location(),
- "Uninitialized storage pointer. Did you mean '<type> memory " + varDecl.name() + "'?"
- );
+ {
+ string errorText{"Uninitialized storage pointer."};
+ if (varDecl.referenceLocation() == VariableDeclaration::Location::Default)
+ errorText += " Did you mean '<type> memory " + varDecl.name() + "'?";
+ m_errorReporter.warning(varDecl.location(), errorText);
+ }
}
else if (dynamic_cast<MappingType const*>(type(varDecl).get()))
m_errorReporter.typeError(
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index c358a519..cad388df 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -928,7 +928,10 @@ void ContractCompiler::appendModifierOrFunctionCode()
);
}
for (VariableDeclaration const* localVariable: modifier.localVariables())
+ {
+ addedVariables.push_back(localVariable);
appendStackVariableInitialisation(*localVariable);
+ }
stackSurplus =
CompilerUtils::sizeOnStack(modifier.parameters()) +
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index e677afc8..15bb7592 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -71,7 +71,7 @@ Json::Value formatErrorWithException(
)
{
string message;
- string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _message, _scannerFromSourceName);
+ string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type, _scannerFromSourceName);
// NOTE: the below is partially a copy from SourceReferenceFormatter
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception);
@@ -271,12 +271,12 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
for (auto const& error: m_compilerStack.errors())
{
- auto err = dynamic_pointer_cast<Error const>(error);
+ Error const& err = dynamic_cast<Error const&>(*error);
errors.append(formatErrorWithException(
*error,
- err->type() == Error::Type::Warning,
- err->typeName(),
+ err.type() == Error::Type::Warning,
+ err.typeName(),
"general",
"",
scannerFromSourceName
@@ -357,7 +357,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
if (errors.size() > 0)
output["errors"] = errors;
- bool parsingSuccess = m_compilerStack.state() >= CompilerStack::State::ParsingSuccessful;
+ bool analysisSuccess = m_compilerStack.state() >= CompilerStack::State::AnalysisSuccessful;
bool compilationSuccess = m_compilerStack.state() == CompilerStack::State::CompilationSuccessful;
/// Inconsistent state - stop here to receive error reports from users
@@ -366,7 +366,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
output["sources"] = Json::objectValue;
unsigned sourceIndex = 0;
- for (auto const& source: parsingSuccess ? m_compilerStack.sourceNames() : vector<string>())
+ for (auto const& source: analysisSuccess ? m_compilerStack.sourceNames() : vector<string>())
{
Json::Value sourceResult = Json::objectValue;
sourceResult["id"] = sourceIndex++;