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