class AdLint::Exam::CBuiltin::W0728

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

Private Instance Methods

check(expr, fun, arg_vars, *) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17648
def check(expr, fun, arg_vars, *)
  args = arg_vars.zip(fun.type.parameter_types)
  args.each_with_index do |(arg_var, param_type), idx|
    next unless param_type && param_type.enum?

    arg_expr = expr.argument_expressions[idx]
    if constant_expression?(arg_expr)
      if arg_var.type.enum?
        W(arg_expr.location) unless arg_var.type.same_as?(param_type)
      end
    end
  end
end
interpreter() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17662
def interpreter
  @interp
end