class AdLint::Exam::CBuiltin::W1055

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 21132
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 21150
def check(ret_stmt, ret_var)
  return unless @cur_fun && ret_var

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