.NAME Derivation from virtual bases

.DESCRIPTION
	Classes should not be derived from virtual bases. 

.COMMENT V7.0

.SEVERITY Advisory

.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 } {
	# Look for a class definition
	if { [::utilities::isTreeOperator $node class] } {
		set ok 1
		# Check if the clase has a base class
		set classHead [::logiscope::treeDown $node 0]
		set baseClasses [::logiscope::treeDown $classHead 2]
		# If the class has base classes, parse them
		if {![string equal [::utilities::getName $baseClasses] none]} {
			::logiscope::forobj curBaseClass $baseClasses treeChild {
				# Check if the storage class is virtual
				set accessList [::logiscope::treeDown $curBaseClass 0]
				::logiscope::forobj curAccess $accessList treeChild {
					if { [::utilities::isTreeOperator $curAccess storage_class] } {
						set curAccessValue [::utilities::treeAtomString $curAccess]
						if {"$curAccessValue" ==  "virtual"} {
							set ok 0
						}
					}
				}
			}
		}
		if { !$ok } {
			::logiscope::addViolation $node
		}
	}
	return 1
}
