Home | History | Annotate | Download | only in Sema
      1 // RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
      2 // expected-no-diagnostics
      3 
      4 #include <stddef.h>
      5 
      6 #pragma pack(4)
      7 
      8 // Baseline
      9 struct s0 {
     10   char f0;
     11   int  f1;
     12 };
     13 extern int a0[offsetof(struct s0, f1) == 4 ? 1 : -1];
     14 
     15 #pragma pack(push, 2)
     16 struct s1 {
     17   char f0;
     18   int  f1;
     19 };
     20 extern int a1[offsetof(struct s1, f1) == 2 ? 1 : -1];
     21 #pragma pack(pop)
     22 
     23 #pragma pack(1)
     24 struct s3_0 {
     25   char f0;
     26   int f1;
     27 };
     28 #pragma pack()
     29 struct s3_1 {
     30   char f0;
     31   int f1;
     32 };
     33 extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1];
     34 extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1];
     35 
     36 // pack(0) is like pack()
     37 #pragma pack(1)
     38 struct s4_0 {
     39   char f0;
     40   int f1;
     41 };
     42 #pragma pack(0)
     43 struct s4_1 {
     44   char f0;
     45   int f1;
     46 };
     47 extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1];
     48 extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1];
     49 
     50 void f() {
     51   #pragma pack(push, 2)
     52   struct s5_0 {
     53     char f0;
     54     struct s2_4_0 {
     55       int f0;
     56     } f1;
     57   };
     58   #pragma pack(pop)
     59   extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1];
     60 }
     61