class AdLint::Exam::CBuiltin::W0727

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 17614
def initialize(phase_ctxt)
  super
  interp = phase_ctxt[:cc1_interpreter]
  interp.on_explicit_conv_performed += T(:check)
  interp.on_implicit_conv_performed += T(:check)
end

Private Instance Methods

check(init_or_expr, orig_var, rslt_var) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17622
def check(init_or_expr, orig_var, rslt_var)
  return unless rslt_var.type.enum?

  val = orig_var.value.unique_sample
  unless rslt_var.type.enumerators.any? { |enum| val == enum.value }
    W(init_or_expr.location)
  end
end