From: Mikko Rasa Date: Fri, 11 Nov 2016 23:19:00 +0000 (+0200) Subject: Recognize superceded assignments even for out variables X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=77e3e702d39a2547a99dd12eea7906d124ba5477;p=libs%2Fgl.git Recognize superceded assignments even for out variables --- diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index 98b11e89..d518ef3a 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -621,7 +621,10 @@ void ProgramCompiler::UnusedVariableLocator::visit(VariableReference &var) unused_nodes.erase(var.declaration); map::iterator i = assignments.find(var.declaration); if(i!=assignments.end()) + { unused_nodes.erase(i->second); + assignments.erase(i); + } } } @@ -650,11 +653,12 @@ void ProgramCompiler::UnusedVariableLocator::visit(ExpressionStatement &expr) TraversingVisitor::visit(expr); if(assignment && assignment_target) { + Node *&assign = assignments[assignment_target]; + if(assign) + unused_nodes.insert(assign); + assign = &expr; if(assignment_target->interface!="out" || (stage->type!=FRAGMENT && !assignment_target->linked_declaration)) - { unused_nodes.insert(&expr); - assignments[assignment_target] = &expr; - } else unused_nodes.erase(assignment_target); }