• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
2 
3 // Stack: [], Alignment: 8
4 
5 #pragma pack(push, 1)
6 // Stack: [8], Alignment: 1
7 
8 #pragma pack(push, 4)
9 // Stack: [8, 1], Alignment: 4
10 
11 // Note that this differs from gcc; pack() in gcc appears to pop the
12 // top stack entry and resets the current alignment. This is both
13 // inconsistent with MSVC, and the gcc documentation. In other cases,
14 // for example changing this to pack(8), I don't even understand what gcc
15 // is doing.
16 
17 #pragma pack()
18 // Stack: [8, 1], Alignment: 8
19 
20 #pragma pack(pop)
21 // Stack: [8], Alignment: 1
22 struct s0 {
23   char f0;
24   short f1;
25 };
26 int a[sizeof(struct s0) == 3 ? 1 : -1];
27 
28 #pragma pack(pop)
29 // Stack: [], Alignment: 8
30 struct s1 {
31   char f0;
32   short f1;
33 };
34 int b[sizeof(struct s1) == 4 ? 1 : -1];
35