.NAME No inaccesible code

.DESCRIPTION
There shall be no dead code: i.e. statement located after break, continue,
return and exit statements.

.SEVERITY Required

.COMMAND tcl

.CODE

::logiscope::include -once common utilities.tcl

proc compute {standardName tree} {
	
	# find the operators in the tree that are leaf operators
	::utilities::filterTree $tree [list [namespace current]::checkLeaf]

}

proc checkLeaf { tree } {

	switch [::utilities::treeOperatorName $tree] {
		goto -
		return -
		break -
		continue {
			set next [::logiscope::treeRight $tree]
			if { "$next" != "NULL" && 
					![::utilities::isTreeOperator $next case] && 
					![::utilities::isTreeOperator $next default] && 
					![::utilities::isTreeOperator $next label] } {
				::logiscope::addViolation $next
			}
		}
		call {
			set name [::utilities::getName [::logiscope::treeGetSon $tree METHOD_ACCESS]]
			if { "$name" == "exit" } {
				set next [::logiscope::treeRight [::logiscope::treeUp $tree]]
				if { "$next" != "NULL"  && 
					![::utilities::isTreeOperator $next label] } {
					::logiscope::addViolation $next
				}
			}
		}
	}
	return 1
}

