class AdLint::Exam::CBuiltin::W0050

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

Private Instance Methods

check(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1309
def check(node)
  unless @label_num_stack.empty?
    @label_num_stack[-1] += 1
    W(node.location) if @label_num_stack[-1] == 258
  end
end
enter_switch_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1301
def enter_switch_statement(node)
  @label_num_stack.push(0)
end
leave_switch_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 1305
def leave_switch_statement(node)
  @label_num_stack.pop
end