.NAME Overload of unary & operator

.DESCRIPTION
	The unary & operator shall not be overloaded. 

.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
  # Look for & operator definitions
  utilities::filterTree $tree [list [namespace current]::check]
}

proc check { node } {
  set funcOp [::logiscope::treeOperator $node]
  # Look for a function declaration
  if {[string equal [::logiscope::opName $funcOp] func_dcltr]} {
    # Get the declaration's first node
    set operatorNode [::logiscope::treeDown $node 0]
    set operatorName [::logiscope::opName [::logiscope::treeOperator $operatorNode]]
	# If the first node is an operator, continue checking
  	if {[string equal $operatorName operator]} {
      set operatorValue [::utilities::getName [::logiscope::treeDown $operatorNode 0]]
	  # If the operator is op_bwand, the rule is violated
	  if {[string equal $operatorValue op_bwand]} {
   	    ::logiscope::addViolation [::logiscope::treeParent $node]
	    return 0
	  }
	}
  }  
  return 1
}
