class AdLint::Exam::CBuiltin::W0781

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 19211
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_switch_statement          += T(:enter_switch_statement)
  trav.leave_switch_statement          += T(:check)
  trav.enter_case_labeled_statement    += T(:add_exec_path)
  trav.enter_default_labeled_statement += T(:add_exec_path)
  @exec_path_nums = []
end

Private Instance Methods

add_exec_path(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 19233
def add_exec_path(node)
  @exec_path_nums[-1] += 1 if node.executed?
end
check(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 19226
def check(node)
  if exec_path_num = @exec_path_nums.last and exec_path_num < 2
    W(node.location)
  end
  @exec_path_nums.pop
end
enter_switch_statement(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 19222
def enter_switch_statement(*)
  @exec_path_nums.push(0)
end