.NAME Compound statement for if

.DESCRIPTION
An if ( condition ) construct shall be followed by 
a compound statement. The else keyword shall be 
followed by either a compound statement, or another if 
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 } {
	if { [::utilities::isTreeOperator $node if] } {
		set thenPart [::logiscope::treeDown $node 1]
		set content [::logiscope::treeDown $thenPart 0]
		if { "$content" != "NULL" && ![::utilities::isTreeOperator $content compound] } {
			::logiscope::addViolation $content
		}
		set elsePart [::logiscope::treeDown $node 2]
		if { ![::utilities::isTreeOperator $elsePart none] } {
			set content [::logiscope::treeDown $elsePart 0]
			if { "$content" != "NULL" && ![::utilities::isTreeOperator $content compound] &&
				 ![::utilities::isTreeOperator $content if]} {
				::logiscope::addViolation $content
			}
		}	
	}
	return 1
}
