aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2016-11-15 10:53:19 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2016-11-15 10:53:19 +0800
commitdad33f80dda1824c87e64ad857f9f075e97a01c8 (patch)
tree818149a0b527afb02ea97c0dc15cd057a8018890
parent58e75c7a48f8166cca41e9017dad351113952ab5 (diff)
downloaddexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.tar
dexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.tar.gz
dexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.tar.bz2
dexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.tar.lz
dexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.tar.xz
dexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.tar.zst
dexon-solidity-dad33f80dda1824c87e64ad857f9f075e97a01c8.zip
Fix inline assembly stack warnings when using variables
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp16
2 files changed, 10 insertions, 7 deletions
diff --git a/Changelog.md b/Changelog.md
index 851f39a0..64db4af8 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -7,6 +7,7 @@ Features:
Bugfixes:
+ * Inline assembly: calculate stack height warning correctly even when local variables are used.
* Parser: disallow empty enum definitions.
* Type checker: disallow conversion between different enum types.
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index 5d920cb7..76c71048 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -216,10 +216,18 @@ public:
size_t numVariables = m_state.variables.size();
int deposit = m_state.assembly.deposit();
std::for_each(_block.statements.begin(), _block.statements.end(), boost::apply_visitor(*this));
- deposit = m_state.assembly.deposit() - deposit;
+
+ // pop variables
+ while (m_state.variables.size() > numVariables)
+ {
+ m_state.assembly.append(solidity::Instruction::POP);
+ m_state.variables.pop_back();
+ }
m_state.assembly.setSourceLocation(_block.location);
+ deposit = m_state.assembly.deposit() - deposit;
+
// issue warnings for stack height discrepancies
if (deposit < 0)
{
@@ -238,12 +246,6 @@ public:
);
}
- // pop variables
- while (m_state.variables.size() > numVariables)
- {
- m_state.assembly.append(solidity::Instruction::POP);
- m_state.variables.pop_back();
- }
}
private: