.NAME Arguments to a function-like macro

.DESCRIPTION
	Arguments to a function-like macro shall not contain 
tokens that look like preprocessing directives. 

.COMMENT V7.0

.SEVERITY Required

.COMMENT
Please refer to the MISRA C++:2008 document for further details (www.misra-cpp.com)

.REQUIRED MISRA_16_0_5 cpp_semantic

.COMMAND tcl

.CODE

::logiscope::include -once common utilities.tcl

proc compute {standardName tree} {
  # Check all ... nodes
  utilities::filterTree $tree [list [namespace current]::check]
}

proc check { node } {
  # Retrieve the list of macros with parameters computed by the context
  set macrosWithArgs [::logiscope::get MISRA_16_0_5 storedMacrosWithArgs]
  # Look for a macro invocation
  if { [::utilities::isTreeOperator $node dcltr_callinit] } {
    # Check if the macro is one with parameters
	if {[expr [lsearch $macrosWithArgs [::utilities::getName [::logiscope::treeDown $node 0]]] != -1]} {
	  # Check if the macro parameters violate the rule
	  checkMacroParams [::logiscope::treeDown $node 1]
	}
  }
return 1
}

# This procedure recursively looks for forbidden preprocessor directives
proc checkMacroParams {node} {
	::logiscope::forobj son $node treeChild {
		checkMacroParams $son
	}
	# The list of forbidden preprocessor calls
	set forbidden_pp [list pp_include pp_define pp_ifdef pp_ifdef_ident pp_undef pp_if pp_elif pp_else_part pp_endif pp_error]
	if {[expr [lsearch $forbidden_pp [::utilities::getName $node]] != -1]} {
	  ::logiscope::addViolation $node
	}
}
