.NAME Logical && or || operator

.DESCRIPTION
The right hand operand of a logical && or || operator 
shall not contain side effects. 

.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 and and or nodes
  utilities::filterTree $tree [list [namespace current]::check]
}

proc checkSon { node } {
	set sonName [::utilities::treeOperatorName $node]
	switch -glob -- $sonName {
		*_ass -
		ass -
		pre_decr -
		post_decr -
		pre_incr -
		post_incr {
			::logiscope::addViolation $node
		}
	}
	return 1
}

proc check { node } {
	set nodeName [::utilities::treeOperatorName $node]
	switch -- $nodeName {
		and -
		or {
			# check sub nodes
			set firstSon [::logiscope::treeDown $node 0]
			utilities::filterTree $firstSon [list [namespace current]::checkSon]
			set secondSon [::logiscope::treeDown $node 1]
			utilities::filterTree $secondSon [list [namespace current]::checkSon]
			return 0
		}
	}
	return 1
}
