aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-02-06 17:53:49 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-02-06 18:07:00 +0800
commit2cbbe5828191707f5e51ba699699bfa4dc6c3691 (patch)
tree7a7c908612a7e58c49ca16155f736a0288115a8d
parentb0407cfac02bf8158385871e651591f9bee44ce0 (diff)
downloaddexon-solidity-2cbbe5828191707f5e51ba699699bfa4dc6c3691.tar.gz
dexon-solidity-2cbbe5828191707f5e51ba699699bfa4dc6c3691.tar.zst
dexon-solidity-2cbbe5828191707f5e51ba699699bfa4dc6c3691.zip
Support variable declarations without assignment in UnusedPruner
-rw-r--r--libjulia/optimiser/UnusedPruner.cpp6
-rw-r--r--test/libjulia/UnusedPruner.cpp8
2 files changed, 12 insertions, 2 deletions
diff --git a/libjulia/optimiser/UnusedPruner.cpp b/libjulia/optimiser/UnusedPruner.cpp
index e33bef78..50f4d9f1 100644
--- a/libjulia/optimiser/UnusedPruner.cpp
+++ b/libjulia/optimiser/UnusedPruner.cpp
@@ -60,12 +60,14 @@ void UnusedPruner::operator()(Block& _block)
[=](TypedName const& _typedName) { return used(_typedName.name); }
))
{
- if (!varDecl.value || MovableChecker(*varDecl.value).movable())
+ if (!varDecl.value)
+ statement = Block{std::move(varDecl.location), {}};
+ else if (MovableChecker(*varDecl.value).movable())
{
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
statement = Block{std::move(varDecl.location), {}};
}
- else if (varDecl.value && varDecl.variables.size() == 1)
+ else if (varDecl.variables.size() == 1)
statement = ExpressionStatement{varDecl.location, FunctionalInstruction{
varDecl.location,
solidity::Instruction::POP,
diff --git a/test/libjulia/UnusedPruner.cpp b/test/libjulia/UnusedPruner.cpp
index e646cee6..48ada5ed 100644
--- a/test/libjulia/UnusedPruner.cpp
+++ b/test/libjulia/UnusedPruner.cpp
@@ -63,6 +63,14 @@ BOOST_AUTO_TEST_CASE(trivial)
);
}
+BOOST_AUTO_TEST_CASE(multi_declarations)
+{
+ CHECK(
+ "{ let x, y }",
+ "{ }"
+ );
+}
+
BOOST_AUTO_TEST_CASE(functions)
{
CHECK(