.NAME Compound statement

.DESCRIPTION
The statement forming the body of a switch, while, 
do ... while or for statement shall be a compound 
statement. 

.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 } {
	
	set nodeNum -1
	set opName [::utilities::treeOperatorName $node]
	
	if { [string equal $opName for] } {		
		set nodeNum 3
	} elseif { [string equal $opName switch] |
		[string equal $opName while] } {
		set nodeNum 1
	} elseif { [string equal $opName do] } {
		set nodeNum 0
	}
	
	if { $nodeNum != -1 } {
		set body [::logiscope::treeDown $node $nodeNum]
		set content [::logiscope::treeDown $body 0]
		if { "$content" != "NULL" && ![::utilities::isTreeOperator $content compound] } {
			::logiscope::addViolation $content
		}			
	}
	return 1
}
