xref: /aosp_15_r20/external/clang/test/Sema/pragma-align-mac68k.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
2*67e74705SXin Li // expected-no-diagnostics
3*67e74705SXin Li 
4*67e74705SXin Li #include <stddef.h>
5*67e74705SXin Li 
6*67e74705SXin Li #pragma options align=mac68k
7*67e74705SXin Li 
8*67e74705SXin Li typedef float __attribute__((vector_size (8))) v2f_t;
9*67e74705SXin Li typedef float __attribute__((vector_size (16))) v4f_t;
10*67e74705SXin Li 
11*67e74705SXin Li extern int a0_0[__alignof(v2f_t) == 8 ? 1 : -1];
12*67e74705SXin Li extern int a0_1[__alignof(v4f_t) == 16 ? 1 : -1];
13*67e74705SXin Li 
14*67e74705SXin Li struct s1 {
15*67e74705SXin Li   char f0;
16*67e74705SXin Li   int  f1;
17*67e74705SXin Li };
18*67e74705SXin Li extern int a1_0[offsetof(struct s1, f0) == 0 ? 1 : -1];
19*67e74705SXin Li extern int a1_1[offsetof(struct s1, f1) == 2 ? 1 : -1];
20*67e74705SXin Li extern int a1_2[sizeof(struct s1) == 6 ? 1 : -1];
21*67e74705SXin Li extern int a1_3[__alignof(struct s1) == 2 ? 1 : -1];
22*67e74705SXin Li 
23*67e74705SXin Li struct s2 {
24*67e74705SXin Li   char f0;
25*67e74705SXin Li   double f1;
26*67e74705SXin Li };
27*67e74705SXin Li extern int a2_0[offsetof(struct s2, f0) == 0 ? 1 : -1];
28*67e74705SXin Li extern int a2_1[offsetof(struct s2, f1) == 2 ? 1 : -1];
29*67e74705SXin Li extern int a2_2[sizeof(struct s2) == 10 ? 1 : -1];
30*67e74705SXin Li extern int a2_3[__alignof(struct s2) == 2 ? 1 : -1];
31*67e74705SXin Li 
32*67e74705SXin Li struct s3 {
33*67e74705SXin Li   char f0;
34*67e74705SXin Li   v4f_t f1;
35*67e74705SXin Li };
36*67e74705SXin Li extern int a3_0[offsetof(struct s3, f0) == 0 ? 1 : -1];
37*67e74705SXin Li extern int a3_1[offsetof(struct s3, f1) == 2 ? 1 : -1];
38*67e74705SXin Li extern int a3_2[sizeof(struct s3) == 18 ? 1 : -1];
39*67e74705SXin Li extern int a3_3[__alignof(struct s3) == 2 ? 1 : -1];
40*67e74705SXin Li 
41*67e74705SXin Li struct s4 {
42*67e74705SXin Li   char f0;
43*67e74705SXin Li   char f1;
44*67e74705SXin Li };
45*67e74705SXin Li extern int a4_0[offsetof(struct s4, f0) == 0 ? 1 : -1];
46*67e74705SXin Li extern int a4_1[offsetof(struct s4, f1) == 1 ? 1 : -1];
47*67e74705SXin Li extern int a4_2[sizeof(struct s4) == 2 ? 1 : -1];
48*67e74705SXin Li extern int a4_3[__alignof(struct s4) == 2 ? 1 : -1];
49*67e74705SXin Li 
50*67e74705SXin Li struct s5 {
51*67e74705SXin Li   unsigned f0 : 9;
52*67e74705SXin Li   unsigned f1 : 9;
53*67e74705SXin Li };
54*67e74705SXin Li extern int a5_0[sizeof(struct s5) == 4 ? 1 : -1];
55*67e74705SXin Li extern int a5_1[__alignof(struct s5) == 2 ? 1 : -1];
56*67e74705SXin Li 
57*67e74705SXin Li struct s6 {
58*67e74705SXin Li   unsigned : 0;
59*67e74705SXin Li   unsigned : 0;
60*67e74705SXin Li };
61*67e74705SXin Li extern int a6_0[sizeof(struct s6) == 0 ? 1 : -1];
62*67e74705SXin Li extern int a6_1[__alignof(struct s6) == 2 ? 1 : -1];
63*67e74705SXin Li 
64*67e74705SXin Li struct s7 {
65*67e74705SXin Li   char : 1;
66*67e74705SXin Li   unsigned : 1;
67*67e74705SXin Li };
68*67e74705SXin Li extern int a7_0[sizeof(struct s7) == 2 ? 1 : -1];
69*67e74705SXin Li extern int a7_1[__alignof(struct s7) == 2 ? 1 : -1];
70*67e74705SXin Li 
71*67e74705SXin Li struct s8 {
72*67e74705SXin Li   char f0;
73*67e74705SXin Li   unsigned : 1;
74*67e74705SXin Li };
75*67e74705SXin Li extern int a8_0[sizeof(struct s8) == 2 ? 1 : -1];
76*67e74705SXin Li extern int a8_1[__alignof(struct s8) == 2 ? 1 : -1];
77*67e74705SXin Li 
78*67e74705SXin Li struct s9 {
79*67e74705SXin Li   char f0[3];
80*67e74705SXin Li   unsigned : 0;
81*67e74705SXin Li   char f1;
82*67e74705SXin Li };
83*67e74705SXin Li extern int a9_0[sizeof(struct s9) == 6 ? 1 : -1];
84*67e74705SXin Li extern int a9_1[__alignof(struct s9) == 2 ? 1 : -1];
85*67e74705SXin Li 
86*67e74705SXin Li struct s10 {
87*67e74705SXin Li   char f0;
88*67e74705SXin Li };
89*67e74705SXin Li extern int a10_0[sizeof(struct s10) == 2 ? 1 : -1];
90*67e74705SXin Li extern int a10_1[__alignof(struct s10) == 2 ? 1 : -1];
91*67e74705SXin Li 
92*67e74705SXin Li struct s11 {
93*67e74705SXin Li   char f0;
94*67e74705SXin Li   v2f_t f1;
95*67e74705SXin Li };
96*67e74705SXin Li extern int a11_0[offsetof(struct s11, f0) == 0 ? 1 : -1];
97*67e74705SXin Li extern int a11_1[offsetof(struct s11, f1) == 2 ? 1 : -1];
98*67e74705SXin Li extern int a11_2[sizeof(struct s11) == 10 ? 1 : -1];
99*67e74705SXin Li extern int a11_3[__alignof(struct s11) == 2 ? 1 : -1];
100*67e74705SXin Li 
101*67e74705SXin Li #pragma options align=reset
102*67e74705SXin Li 
f12(void)103*67e74705SXin Li void f12(void) {
104*67e74705SXin Li   #pragma options align=mac68k
105*67e74705SXin Li   struct s12 {
106*67e74705SXin Li     char f0;
107*67e74705SXin Li     int  f1;
108*67e74705SXin Li   };
109*67e74705SXin Li   #pragma options align=reset
110*67e74705SXin Li   extern int a12[sizeof(struct s12) == 6 ? 1 : -1];
111*67e74705SXin Li }
112