.NAME NULL thrown

.DESCRIPTION
NULL shall not be thrown explicitly. 

.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 curOperator [::logiscope::treeOperator $node]
  set curOperatorName [::logiscope::opName $curOperator]
  # Look for a throw
  if {[string equal $curOperatorName throw]} {
    # Check if the child is an identifier or an expression
	set directChild [::logiscope::treeDown $node 0]
	set directChildName [::utilities::getName $directChild]
	
	# The "throw null" and "throw NULL" situations are detected
	if {[string equal [string toupper $directChildName] NULL]} {
	  ::logiscope::addViolation $node
	  return 0
	}
	# The "throw (null)" and "throw (NULL)" situations are detected
	if {[string equal $directChildName parenth_expr]} {
	  set secondaryChild [::logiscope::treeDown $directChild 0]
	  set secondaryChildName [::utilities::getName $secondaryChild]
		if {[string equal [string toupper $secondaryChildName] NULL]} {
		::logiscope::addViolation $node
		return 0
		}
	}
  }
return 1
}
