class AdLint::Exam::CBuiltin::W0119

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

Private Instance Methods

char_type_family?(type) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 3198
def char_type_family?(type)
  type == char_t || type == signed_char_t || type == unsigned_char_t
end
check(init_or_expr, from_var, to_var) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 3167
def check(init_or_expr, from_var, to_var)
  if match?(from_var, to_var)
    W(init_or_expr.location)
  end
end
from_type() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 3173
def from_type
  char_t
end
interpreter() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 3202
def interpreter
  @interp
end
match?(from_var, to_var) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 3181
def match?(from_var, to_var)
  unless from_var.type.same_as?(from_type) && to_var.type.same_as?(to_type)
    return false
  end

  if char_type_family?(from_type) &&
      from_var.type.explicitly_signed? != from_type.explicitly_signed?
    return false
  end
  if char_type_family?(to_type) &&
      to_var.type.explicitly_signed? != to_type.explicitly_signed?
    return false
  end

  true
end
to_type() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 3177
def to_type
  signed_char_t
end