class AdLint::Exam::CBuiltin::W1058

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 21236
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 21254
def check(ret_stmt, ret_var)
  return unless @cur_fun && ret_var
  return if constant_expression?(ret_stmt.expression)

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