class AdLint::Exam::CBuiltin::W0703
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 16177 def initialize(phase_ctxt) super interp = phase_ctxt[:cc1_interpreter] interp.on_struct_declared += T(:declare_struct) interp.on_union_declared += T(:declare_union) interp.on_enum_declared += T(:declare_enum) interp.on_block_started += T(:enter_scope) interp.on_block_ended += T(:leave_scope) @tag_names = [[]] end
Private Instance Methods
declare_enum(enum_dcl)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16219 def declare_enum(enum_dcl) tag_name = enum_dcl.identifier pair_names = @tag_names.flatten.select { |id| id.value == tag_name.value } unless pair_names.empty? W(enum_dcl.location, tag_name.value, *pair_names.map { |pair| C(:C0001, pair.location, pair.value) }) end @tag_names.last.push(tag_name) end
declare_struct(struct_dcl)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16189 def declare_struct(struct_dcl) tag_name = struct_dcl.identifier pair_names = @tag_names.flatten.select { |id| id.value == tag_name.value } unless pair_names.empty? W(struct_dcl.location, tag_name.value, *pair_names.map { |pair| C(:C0001, pair.location, pair.value) }) end @tag_names.last.push(tag_name) end
declare_union(union_dcl)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16204 def declare_union(union_dcl) tag_name = union_dcl.identifier pair_names = @tag_names.flatten.select { |id| id.value == tag_name.value } unless pair_names.empty? W(union_dcl.location, tag_name.value, *pair_names.map { |pair| C(:C0001, pair.location, pair.value) }) end @tag_names.last.push(tag_name) end
enter_scope(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16234 def enter_scope(*) @tag_names.push([]) end
leave_scope(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 16238 def leave_scope(*) @tag_names.pop end