Skip to content
  • Daniel Dunbar's avatar
    Implement #pragma pack use in structure packing. The general approach · 4290d46b
    Daniel Dunbar authored
    is to encode the state of the #pragma pack stack as an attribute when
    the structure is declared. 
    
     - Extend PackedAttr to take an alignment (in bits), and reuse for
       both __attribute__((packed)) (which takes no argument, instead
       packing tightly (to "minimize the memory required") and for #pragma
       pack (which allows specification of the maximum alignment in
       bytes). __attribute__((packed)) is just encoded as Alignment=1.
    
       This conflates two related but different mechanisms, but it didn't
       seem worth another attribute.
    
     - I have attempted to follow the MSVC semantics as opposed to the gcc
       ones, since if I understand correctly #pragma pack originated with
       MSVC. The semantics are generally equivalent except when the stack
       is altered during the definition of a structure; its not clear if
       anyone does this in practice. See testcase if curious.
    
    llvm-svn: 57623
    4290d46b
Loading