aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-01-23 22:02:22 +0800
committerGitHub <noreply@github.com>2017-01-23 22:02:22 +0800
commit9c278448c8f61f752393b7950df3b47d3d5d0437 (patch)
tree798d1627a86783dda5e42d5702ae7cfbad6224f1
parentc382ce1f6b2542f39832d4fd3120851240f4a8c8 (diff)
parent2536bdd6d0dfa1685967fd3106c682e0bcf17021 (diff)
downloaddexon-solidity-9c278448c8f61f752393b7950df3b47d3d5d0437.tar.gz
dexon-solidity-9c278448c8f61f752393b7950df3b47d3d5d0437.tar.zst
dexon-solidity-9c278448c8f61f752393b7950df3b47d3d5d0437.zip
Merge pull request #1591 from ethereum/stackTooDeepLocation
Report source location on "stack too deep" errors.
-rw-r--r--Changelog.md3
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp9
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp7
3 files changed, 16 insertions, 3 deletions
diff --git a/Changelog.md b/Changelog.md
index b9e4ecc0..5e458bba 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,7 +1,8 @@
### 0.4.9 (unreleased)
Features:
- * Compiler Interface: Contracts and libraries can be referenced with a `file:` prefix to make them unique.
+ * Compiler interface: Contracts and libraries can be referenced with a ``file:`` prefix to make them unique.
+ * Compiler interface: Report source location for "stack too deep" errors.
* AST: Use deterministic node identifiers.
* Type system: Introduce type identifier strings.
* Metadata: Do not include platform in the version number.
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index fa77c1aa..bdff0da4 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -486,7 +486,12 @@ bool ContractCompiler::visit(FunctionDefinition const& _function)
stackLayout.push_back(i);
stackLayout += vector<int>(c_localVariablesSize, -1);
- solAssert(stackLayout.size() <= 17, "Stack too deep, try removing local variables.");
+ if (stackLayout.size() > 17)
+ BOOST_THROW_EXCEPTION(
+ CompilerError() <<
+ errinfo_sourceLocation(_function.location()) <<
+ errinfo_comment("Stack too deep, try removing local variables.")
+ );
while (stackLayout.back() != int(stackLayout.size() - 1))
if (stackLayout.back() < 0)
{
@@ -551,6 +556,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
if (stackDiff < 1 || stackDiff > 16)
BOOST_THROW_EXCEPTION(
CompilerError() <<
+ errinfo_sourceLocation(_inlineAssembly.location()) <<
errinfo_comment("Stack too deep, try removing local variables.")
);
for (unsigned i = 0; i < variable->type()->sizeOnStack(); ++i)
@@ -591,6 +597,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
if (stackDiff > 16 || stackDiff < 1)
BOOST_THROW_EXCEPTION(
CompilerError() <<
+ errinfo_sourceLocation(_inlineAssembly.location()) <<
errinfo_comment("Stack too deep, try removing local variables.")
);
for (unsigned i = 0; i < size; ++i) {
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 37bd1458..81d3409e 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -250,7 +250,12 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
}
if (lvalueSize > 0)
{
- solAssert(itemSize + lvalueSize <= 16, "Stack too deep, try removing local variables.");
+ if (itemSize + lvalueSize > 16)
+ BOOST_THROW_EXCEPTION(
+ CompilerError() <<
+ errinfo_sourceLocation(_assignment.location()) <<
+ errinfo_comment("Stack too deep, try removing local variables.")
+ );
// value [lvalue_ref] updated_value
for (unsigned i = 0; i < itemSize; ++i)
m_context << swapInstruction(itemSize + lvalueSize) << Instruction::POP;