class AdLint::Exam::CBuiltin::W0564
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 13015 def initialize(phase_ctxt) super trav = phase_ctxt[:cc1_ast_traversal] trav.enter_compound_statement += T(:enter_block) trav.leave_compound_statement += T(:leave_block) trav.enter_generic_labeled_statement += T(:check) @blocks = [] end
Private Instance Methods
check(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13025 def check(node) return if node.referrers.empty? if @blocks.size > 1 cur_block = @blocks.last posterior_goto = node.referrers.find { |goto| goto.location.line_no > cur_block.tail_location.line_no } return unless posterior_goto # FIXME: Must consider that the declaration may appear at anywhere in # ISO C99. cur_block_items = cur_block.block_items if cur_block_items.any? { |item| item.kind_of?(Cc1::Declaration) } W(posterior_goto.location, node.label.value) end end end
enter_block(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13044 def enter_block(node) @blocks.push(node) end
leave_block(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13048 def leave_block(node) @blocks.pop end