.NAME Label of goto

.DESCRIPTION
	The goto statement shall jump to a label declared later 
in the same function body. 

.COMMENT V7.0

.SEVERITY Required

.COMMENT
Please refer to the MISRA C++:2008 document for further details (www.misra-cpp.com)

.COMMAND tcl

.CODE

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

proc compute {standardName tree} {
  variable CurrentParameterList
  # Check all ... nodes
  utilities::filterTree $tree [list [namespace current]::check]
}

proc check { node } {
    # Look for #define 
	variable listLabels
	if { [::utilities::isTreeOperator $node fndef] } {
		set fnBody [::logiscope::treeGetSon $node FNBODY]
		set listLabels ""
		parseFnBody $node
	}
return 1
}

proc parseFnBody {node} {
	variable listLabels
	if { [::utilities::isTreeOperator $node label] } {
		lappend listLabels [::utilities::getName [::logiscope::treeGetSon $node IDENTIFIER]]
	}
	
	if { [::utilities::isTreeOperator $node goto] } {
	if {[expr [lsearch $listLabels [::utilities::getName [::logiscope::treeGetSon $node IDENTIFIER]]] != -1]} {
			::logiscope::addViolation $node
		}
	}
	
	::logiscope::forobj child $node treeChild {
		parseFnBody $child
	}		
}
