aggregate(0),
assignment(0),
assignment_target(false),
+ assign_to_subscript(false),
global_scope(true)
{ }
{
if(binary.oper=="[")
{
+ if(assignment_target)
+ assign_to_subscript = true;
binary.left->visit(*this);
SetForScope<bool> set(assignment_target, false);
binary.right->visit(*this);
void ProgramCompiler::UnusedVariableLocator::visit(Assignment &assign)
{
{
+ assign_to_subscript = false;
SetForScope<bool> set(assignment_target, !assign.self_referencing);
assign.left->visit(*this);
}
assignment = &assign;
}
-void ProgramCompiler::UnusedVariableLocator::record_assignment(VariableDeclaration &var, Node &node, bool self_ref)
+void ProgramCompiler::UnusedVariableLocator::record_assignment(VariableDeclaration &var, Node &node, bool chained)
{
VariableInfo &var_info = variables.back()[&var];
- if(!self_ref)
+ if(!chained)
clear_assignments(var_info, true);
var_info.assignments.push_back(&node);
var_info.conditionally_assigned = false;
assignment = 0;
TraversingVisitor::visit(expr);
if(assignment && assignment->target_declaration)
- record_assignment(*assignment->target_declaration, expr, assignment->self_referencing);
+ record_assignment(*assignment->target_declaration, expr, (assignment->self_referencing || assign_to_subscript));
}
void ProgramCompiler::UnusedVariableLocator::visit(StructDeclaration &strct)