class AdLint::Exam::CBuiltin::W0563
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 12970 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 12980 def check(node) return if node.referrers.empty? if @blocks.size > 1 cur_block = @blocks.last anterior_goto = node.referrers.find { |goto| goto.location.line_no < cur_block.head_location.line_no } return unless anterior_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(node.location, node.label.value) end end end
enter_block(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12999 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 13003 def leave_block(node) @blocks.pop end