class AdLint::Exam::CBuiltin::W0698

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 16079
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_ansi_function_definition  += T(:start_function)
  trav.enter_kandr_function_definition += T(:start_function)
  trav.leave_ansi_function_definition  += T(:end_function)
  trav.leave_kandr_function_definition += T(:end_function)
  trav.enter_return_statement          += T(:check)
  @cur_fun = nil
end

Private Instance Methods

check(ret_stmt) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16099
def check(ret_stmt)
  return unless @cur_fun.explicitly_typed?

  if ret_type = @cur_fun.type.return_type
    if !ret_type.void? && ret_stmt.expression.nil?
      W(ret_stmt.location, @cur_fun.identifier.value)
    end
  end
end
end_function(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16095
def end_function(*)
  @cur_fun = nil
end
start_function(fun_def) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16091
def start_function(fun_def)
  @cur_fun = fun_def
end