.NAME Class destructor

.DESCRIPTION
	A class destructor shall not exit with an exception. 

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

proc check { node } {
	variable isDestructor
	variable throwFound
	variable catchFound
	if { [::utilities::isTreeOperator $node func_dcltr] } {
		# if a son is "destructor", this is a destructor
		set isDestructor 0
		::utilities::checkForOperator $node destructor [namespace current]::isDestructor
		if { $isDestructor } {
			# check content
			set brother [::logiscope::treeRight $node]
			if { "$brother" != "NULL" } {
				set compound [::logiscope::treeRight $brother]
				if { [::utilities::isTreeOperator $compound compound] } {
					# if a throw is found then a catch is mandatory
					# types of throw not checked in this version
					set throwFound 0
					::utilities::checkForOperator $compound throw [namespace current]::throwFound
					if { $throwFound } {
						set catchFound 0
						::utilities::checkForOperator $compound try_handlers [namespace current]::catchFound
						if { $catchFound == 0 } {
							::logiscope::addViolation $node
						}
					}
				}
			}
		}
	}
	return 1
}
