summary refs log blame commit diff stats
path: root/tests/pragmas/tbitsize.nim
blob: 39aee445f202314b972ba2b48ad12d4095b744af (plain) (tree)
1
2
3
4
5
6
7
8
9



                                            

                
                               

                              


         
                    
          
                    
          
                    

          
                    
          
                     
discard """
ccodeCheck: "\\i @'unsigned int flag:1;' .*"
"""

type
  bits* = object
    flag* {.bitsize: 1.}: cuint
    opts* {.bitsize: 4.}: cint

var
  b: bits

doAssert b.flag == 0
b.flag = 1
doAssert b.flag == 1
b.flag = 2
doAssert b.flag == 0

b.opts = 7
doAssert b.opts == 7
b.opts = 9
doAssert b.opts == -7