From dad33f80dda1824c87e64ad857f9f075e97a01c8 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 15 Nov 2016 02:53:19 +0000 Subject: Fix inline assembly stack warnings when using variables --- libsolidity/inlineasm/AsmCodeGen.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'libsolidity/inlineasm/AsmCodeGen.cpp') 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: -- cgit