class AdLint::Exam::CBuiltin::W9003

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 21935
def initialize(phase_ctxt)
  super
  @interp = phase_ctxt[:cc1_interpreter]
  @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 21942
def check(init_or_expr, orig_var, rslt_var)
  from_type = orig_var.type
  to_type = rslt_var.type

  if from_type.undeclared? || from_type.unresolved? ||
      to_type.undeclared? || to_type.unresolved?
    return
  end

  case init_or_expr
  when Cc1::Initializer
    expr = init_or_expr.expression
    if expr && constant_expression?(expr)
      if untyped_pointer_conversion?(from_type, to_type, orig_var.value)
        return
      end
    end
  when Cc1::Expression
    if constant_expression?(init_or_expr)
      if untyped_pointer_conversion?(from_type, to_type, orig_var.value)
        return
      end
    end
  end

  unless from_type.standard? && to_type.standard?
    unless from_type.convertible?(to_type)
      W(init_or_expr.location, from_type.brief_image, to_type.brief_image)
    end
  end
end
interpreter() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21974
def interpreter
  @interp
end