.NAME Include directive

.DESCRIPTION
	#include directives in a file shall only be preceded by 
other preprocessor directives or comments. 

.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 allowed
  
  set allowed 1
  # Check all nodes
  utilities::filterTree $tree [list [namespace current]::check]
}

proc check { node } {
	variable allowed

	switch -glob -- [::utilities::treeOperatorName $node] {
		pp_* {
			if { !$allowed && [::utilities::isTreeOperator $node pp_include] } {
				::logiscope::addViolation $node
			}
			if { ![::utilities::isTreeOperator $node pp_conditional] } {
				return 0
			}
		}
		extdecl -
		fndef {
			set allowed 0
		}
	}
	return 1
}
