class AdLint::Exam::CBuiltin::W1060

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 21301
def initialize(phase_ctxt)
  super
  interp = phase_ctxt[:cc1_interpreter]
  interp.on_function_started   += T(:start_function)
  interp.on_function_ended     += T(:end_function)
  interp.on_return_stmt_evaled += T(:check)
  @cur_fun  = nil
end

Private Instance Methods

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

  if ret_type = @cur_fun.type.return_type and !ret_type.enum?
    W(ret_stmt.expression.location) if ret_var.type.enum?
  end
end
end_function(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21315
def end_function(*)
  @cur_fun = nil
end
start_function(*, fun) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21311
def start_function(*, fun)
  @cur_fun = fun
end