class AdLint::Exam::CBuiltin::W0790

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 19637
def initialize(phase_ctxt)
  super
  interp = phase_ctxt[:cc1_interpreter]
  interp.on_variable_defined          += T(:check)
  interp.on_explicit_function_defined += T(:check)
  @global_names = Hash.new { |hash, key| hash[key] = [] }
end

Private Instance Methods

check(var_or_fun_def, obj) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 19646
def check(var_or_fun_def, obj)
  if obj.declared_as_extern?
    name = var_or_fun_def.identifier
    if @global_names.include?(name.value)
      W(var_or_fun_def.location, name.value,
        *@global_names[name.value].map { |pair_name|
          C(:C0001, pair_name.location, pair_name.value)
        })
    end
    @global_names[name.value].push(name)
  end
end