xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/2007-09-12-PragmaPack.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc typedef unsigned char uint8_t;
4*f4a2713aSLionel Sambuc typedef unsigned short uint16_t;
5*f4a2713aSLionel Sambuc typedef unsigned int uint32_t;
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc #pragma pack(push, 1)
8*f4a2713aSLionel Sambuc typedef struct
9*f4a2713aSLionel Sambuc {
10*f4a2713aSLionel Sambuc         uint32_t        a;
11*f4a2713aSLionel Sambuc } foo;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc typedef struct {
14*f4a2713aSLionel Sambuc         uint8_t         major;
15*f4a2713aSLionel Sambuc         uint8_t         minor;
16*f4a2713aSLionel Sambuc         uint16_t        build;
17*f4a2713aSLionel Sambuc } VERSION;
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc typedef struct {
20*f4a2713aSLionel Sambuc         uint8_t       a[5];
21*f4a2713aSLionel Sambuc         VERSION       version;
22*f4a2713aSLionel Sambuc         uint8_t       b;
23*f4a2713aSLionel Sambuc         foo           d;
24*f4a2713aSLionel Sambuc         uint32_t      guard;
25*f4a2713aSLionel Sambuc } bar;
26*f4a2713aSLionel Sambuc #pragma pack(pop)
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc 
barsize(void)29*f4a2713aSLionel Sambuc unsigned barsize(void) {
30*f4a2713aSLionel Sambuc   // CHECK: ret i32 18
31*f4a2713aSLionel Sambuc   return sizeof(bar);
32*f4a2713aSLionel Sambuc }
33