]> git.tdb.fi Git - libs/gl.git/commitdiff
Recognize superceded assignments even for out variables
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Nov 2016 23:19:00 +0000 (01:19 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Nov 2016 23:19:00 +0000 (01:19 +0200)
source/programcompiler.cpp

index 98b11e89b834d48a665e8e4059bfe306d882a7af..d518ef3aa5fb6d8fd93c8cace2cc71502f771eba 100644 (file)
@@ -621,7 +621,10 @@ void ProgramCompiler::UnusedVariableLocator::visit(VariableReference &var)
                unused_nodes.erase(var.declaration);
                map<VariableDeclaration *, Node *>::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);
        }