class AdLint::Exam::CBuiltin::W1069

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 21580
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_ansi_function_definition  += T(:enter_function)
  trav.enter_kandr_function_definition += T(:enter_function)
  trav.enter_compound_statement        += T(:enter_compound_stmt)
  trav.leave_compound_statement        += T(:leave_compound_stmt)
  trav.enter_if_else_statement         += T(:enter_if_else_stmt)
  trav.leave_if_else_statement         += T(:leave_if_else_stmt)
  @if_else_stmt_chain_stack = []
end

Private Instance Methods

enter_compound_stmt(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21597
def enter_compound_stmt(*)
  @if_else_stmt_chain_stack.push([])
end
enter_function(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21593
def enter_function(*)
  @if_else_stmt_chain_stack = []
end
enter_if_else_stmt(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21605
def enter_if_else_stmt(node)
  @if_else_stmt_chain_stack.last.push(node)
  if node.else_statement.kind_of?(Cc1::IfStatement)
    W(@if_else_stmt_chain_stack.last.first.location)
  end
end
leave_compound_stmt(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21601
def leave_compound_stmt(*)
  @if_else_stmt_chain_stack.pop
end
leave_if_else_stmt(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 21612
def leave_if_else_stmt(*)
  @if_else_stmt_chain_stack.last.pop
end