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