class AdLint::Exam::CBuiltin::W0066

Public Class Methods

new(phase_ctxt) click to toggle source
Calls superclass method AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1531
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_ansi_function_definition  += T(:check_ansi_function)
  trav.enter_kandr_function_definition += T(:check_kandr_function)
  @interp = phase_ctxt[:cc1_interpreter]
end

Private Instance Methods

argc_type() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1568
def argc_type
  int_t
end
argv_type() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1572
def argv_type
  array_type(pointer_type(char_t))
end
check(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1548
def check(node)
  unless node.type.return_type == int_t
    W(node.location)
    return
  end

  if node.type.parameter_types.size == 1 &&
      node.type.parameter_types[0] == void_t
    return
  end

  if node.type.parameter_types.size == 2 &&
      node.type.parameter_types[0] == argc_type &&
      node.type.parameter_types[1] == argv_type
    return
  end

  W(node.location)
end
check_ansi_function(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1540
def check_ansi_function(node)
  check(node) if node.identifier.value == "main"
end
check_kandr_function(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1544
def check_kandr_function(node)
  check(node) if node.identifier.value == "main"
end
interpreter() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1576
def interpreter
  @interp
end