class AdLint::Exam::CBuiltin::W0562
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 12927 def initialize(phase_ctxt) super trav = phase_ctxt[:cc1_ast_traversal] trav.enter_variable_definition += T(:check) end
Private Instance Methods
check(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12934 def check(node) if init = node.initializer if initializer_depth(init) > type_depth(node.type) W(init.location) end end end
initializer_depth(init)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12942 def initializer_depth(init) if inits = init.initializers 1 + inits.map { |i| initializer_depth(i) }.max else 0 end end
type_depth(type)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12950 def type_depth(type) case when type.array? 1 + type_depth(type.base_type) when type.composite? type.members.empty? ? 1 : 1 + type.members.map { |memb| type_depth(memb.type) }.max else 0 end end