class AdLint::Exam::CBuiltin::W0731
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 17748 def initialize(phase_ctxt) super interp = phase_ctxt[:cc1_interpreter] interp.on_switch_stmt_ended += T(:end_switch_statement) interp.on_switch_ctrlexpr_evaled += T(:memorize_switch_ctrlexpr) interp.on_case_ctrlexpr_evaled += T(:check) @switch_ctrlexpr_stack = [] end
Private Instance Methods
check(case_stmt, ctrlexpr_var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17766 def check(case_stmt, ctrlexpr_var) unless switch_ctrlexpr_var = @switch_ctrlexpr_stack.last return end return unless switch_ctrlexpr_var.type.enum? expected_type = switch_ctrlexpr_var.type val = ctrlexpr_var.value.unique_sample unless expected_type.enumerators.any? { |enum| val == enum.value } W(case_stmt.expression.location, case_stmt.expression.to_s) end end
end_switch_statement(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17758 def end_switch_statement(*) @switch_ctrlexpr_stack.pop end
memorize_switch_ctrlexpr(*, ctrlexpr_var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17762 def memorize_switch_ctrlexpr(*, ctrlexpr_var) @switch_ctrlexpr_stack.push(ctrlexpr_var) end