class AdLint::Exam::CBuiltin::W0949

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 20399
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_struct_declarator += T(:check)
  @interp = Cc1::Interpreter.new(phase_ctxt[:cc1_type_table])
end

Private Instance Methods

check(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 20407
def check(node)
  if node.kind_of?(Cc1::StructDeclarator)
    if expr = node.expression and
        expr.kind_of?(Cc1::ConstantSpecifier) && !expr.constant.replaced?
      bitfield_width = compute_bitfield_width(expr)
      W(expr.location, expr.constant.value) if bitfield_width > 1
    end
  end
end
compute_bitfield_width(expr) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 20417
def compute_bitfield_width(expr)
  obj = interpret(expr, QUIET)
  if obj.variable? && obj.value.scalar?
    obj.value.unique_sample || 0
  else
    0
  end
end
interpreter() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 20426
def interpreter
  @interp
end