blob: c6cd7543c21d4fd9fbfccf212846e4e6c9f89473 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
Eli Friedmanc5082032009-02-22 03:31:23 +00002
3// PR3433
4double g1;
5short chk1[__alignof__(g1) == 8 ? 1 : -1];
Eli Friedman1eed6022009-05-25 21:27:19 +00006short chk2[__alignof__(double) == 8 ? 1 : -1];
7
8long long g2;
9short chk1[__alignof__(g2) == 8 ? 1 : -1];
10short chk2[__alignof__(long long) == 8 ? 1 : -1];
11
Chad Rosiercde7a1d2012-03-21 20:20:47 +000012unsigned long long g5;
13short chk1[__alignof__(g5) == 8 ? 1 : -1];
14short chk2[__alignof__(unsigned long long) == 8 ? 1 : -1];
15
Eli Friedman1eed6022009-05-25 21:27:19 +000016_Complex double g3;
17short chk1[__alignof__(g3) == 8 ? 1 : -1];
18short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];
Charles Davis05f62472010-02-23 04:52:00 +000019
20// PR6362
Carl Norume224ba72011-03-07 22:57:45 +000021struct __attribute__((packed)) {unsigned int a;} g4;
Charles Davis05f62472010-02-23 04:52:00 +000022short chk1[__alignof__(g4) == 1 ? 1 : -1];
23short chk2[__alignof__(g4.a) == 1 ? 1 : -1];
24
Argyrios Kyrtzidiscd88b412011-04-26 21:05:39 +000025
26// PR5637
27
28#define ALIGNED(x) __attribute__((aligned(x)))
29
30typedef ALIGNED(2) struct {
31 char a[3];
32} T;
33
34short chk1[sizeof(T) == 3 ? 1 : -1];
35short chk2[sizeof(T[1]) == 4 ? 1 : -1];
36short chk3[sizeof(T[2]) == 6 ? 1 : -1];
37short chk4[sizeof(T[2][1]) == 8 ? 1 : -1];
38short chk5[sizeof(T[1][2]) == 6 ? 1 : -1];
39
40typedef struct ALIGNED(2) {
41 char a[3];
42} T2;
43
44short chk1[sizeof(T2) == 4 ? 1 : -1];
45short chk2[sizeof(T2[1]) == 4 ? 1 : -1];
46short chk3[sizeof(T2[2]) == 8 ? 1 : -1];
47short chk4[sizeof(T2[2][1]) == 8 ? 1 : -1];
48short chk5[sizeof(T2[1][2]) == 8 ? 1 : -1];