.NAME Operand of logical && or ||

.DESCRIPTION
Each operand of a logical && or || shall be a postfix-expression. 

.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 { son allowed } {
	set sonName [::utilities::treeOperatorName $son]
	if { "$sonName" != "$allowed" } {
		switch -- $sonName {
			identifier -
			parenth_expr -
			dot -
			arrow -
			call -
			selected_component -
			compound_name {
				# ok son allowed
			}
			default {
				::logiscope::addViolation $son
			}
		}
	}
}

proc check { node } {
	set nodeName [::utilities::treeOperatorName $node]
	switch -- $nodeName {
		and -
		or {
			# only identifiers and parenthesed expressions allowed as parameters
			set firstSon [::logiscope::treeDown $node 0]
			checkSon $firstSon $nodeName
			set secondSon [::logiscope::treeDown $node 1]
			checkSon $secondSon $nodeName
		}
	}
	return 1
}
