ProgramCompiler::UnusedVariableLocator::UnusedVariableLocator():
aggregate(0),
assignment(0),
- assignment_target(false)
+ assignment_target(false),
+ iteration(false)
{ }
void ProgramCompiler::UnusedVariableLocator::apply(Stage &s)
if(assignment_target)
return;
+ if(iteration)
+ used_in_iteration.insert(var.declaration);
+
for(vector<BlockAssignmentMap>::iterator j=assignments.end(); j!=assignments.begin(); )
{
--j;
void ProgramCompiler::UnusedVariableLocator::record_assignment(VariableDeclaration &var, Node &node, bool self_ref)
{
- unused_nodes.insert(&node);
+ if(!used_in_iteration.count(&var))
+ unused_nodes.insert(&node);
BlockAssignmentMap &block_assignments = assignments.back();
AssignmentList &var_assignments = block_assignments[&var];
if(!self_ref)
void ProgramCompiler::UnusedVariableLocator::visit(Iteration &iter)
{
assignments.push_back(BlockAssignmentMap());
- TraversingVisitor::visit(iter);
+ {
+ SetFlag set(iteration);
+ TraversingVisitor::visit(iter);
+ }
merge_down_assignments();
+ if(!iteration)
+ used_in_iteration.clear();
}