class AdLint::Cc1::EnumType
Attributes
image[RW]
location[RW]
Public Class Methods
new(type_tbl, type_dcl)
click to toggle source
Calls superclass method
AdLint::Cc1::IntegerType::new
# File lib/adlint/cc1/type.rb, line 4958 def initialize(type_tbl, type_dcl) # FIXME: StandardTypeCatalogAccessor is not ready until @type_table is # initialized. @type_table = type_tbl super(type_tbl, type_dcl.identifier.value, int_size, int_alignment, true, true, [type_dcl]) @image = type_dcl.enum_specifier.to_s @location = type_dcl.location end
Public Instance Methods
arithmetic_type_with(type)
click to toggle source
# File lib/adlint/cc1/type.rb, line 5062 def arithmetic_type_with(type) type._arithmetic_type_with_enum(self) end
bitfield?()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4995 def bitfield? false end
brief_image()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4999 def brief_image "enum #{name}" end
corresponding_signed_type()
click to toggle source
# File lib/adlint/cc1/type.rb, line 5066 def corresponding_signed_type signed_int_t end
corresponding_unsigned_type()
click to toggle source
# File lib/adlint/cc1/type.rb, line 5070 def corresponding_unsigned_type unsigned_int_t end
dup()
click to toggle source
# File lib/adlint/cc1/type.rb, line 5074 def dup EnumType.new(type_table, declarations.first) end
enum?()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4987 def enum? true end
enumerators()
click to toggle source
# File lib/adlint/cc1/type.rb, line 5003 def enumerators declarations.map { |dcl| dcl.enumerators }.compact.flatten.uniq end
id()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4971 def id @id ||= EnumTypeId.new(name) end
incomplete?()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4979 def incomplete? declarations.all? { |dcl| dcl.enumerators.nil? } end
integer_conversion_rank()
click to toggle source
# File lib/adlint/cc1/type.rb, line 5007 def integer_conversion_rank # NOTE: The ISO C99 standard says; # # 6.3.1 Arithmetic operands # 6.3.1.1 Boolean, characters, and integers # # 1 Every integer type has an integer conversion rank defined as follows: # # -- No two signed integer types shall have the same rank, even if # they have the same representation. # -- The rank of a signed integer type shall be greater than the rank # of any signed integer type with less precision. # -- The rank of long long int shall be greater than the rank of long # int, which shall be greater than the rank of int, which shall be # greater than the rank of short int, which shall be greater than # the rank of signed char. # -- The rank of any unsigned integer type shall equal the rank of # the corresponding signed integer type, if any. # -- The rank of any standard integer type shall be greater than the # rank of any extended integer type with the same width. # -- The rank of char shall equal the rank of signed char and # unsigned char. # -- The rank of _Bool shall be less than the rank of all other # standard integer types. # -- The rank of any enumerated type shall equal the rank of the # compatible integer type. # -- The rank of any extended signed integer type relative to another # extended signed integer type with the same precision is # implementation-defined, but still subject to the other rules for # determining the integer conversion rank. # -- For all integer types T1, T2, and T3, if T1 has greater rank # than T2 and T2 has greater rank than T3, then T1 has greater # rank than T3. # # NOTE: The integer conversion rank of any enumerated type is equal to # the rank of int. int_t.integer_conversion_rank end
integer_promoted_type()
click to toggle source
# File lib/adlint/cc1/type.rb, line 5046 def integer_promoted_type # NOTE: Any enumerated type should be treated as `int'. # But AdLint internally treats enumerated type as itself, and omits # integer-promotion of any enumerated type in order not to # over-warn about enum-enum expressions like below; # # static void foo(enum Color c) # { # if (c == RED) { /* No usual-arithmetic-conversion of # enumerated types and no W9003 warning */ # ... # } # } self end
named?()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4975 def named? declarations.all? { |dcl| !dcl.enum_specifier.anonymous? } end
pointer?()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4983 def pointer? false end
standard?()
click to toggle source
# File lib/adlint/cc1/type.rb, line 4991 def standard? false end