Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s |
Daniel Dunbar | 396b2a2 | 2009-02-16 23:37:57 +0000 | [diff] [blame] | 2 | |
| 3 | int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}} |
Eli Friedman | dcdafb6 | 2009-02-22 02:56:25 +0000 | [diff] [blame] | 4 | |
| 5 | // PR3254 |
| 6 | short g0[3] __attribute__((aligned)); |
| 7 | short g0_chk[__alignof__(g0) == 16 ? 1 : -1]; |
Douglas Gregor | 1885764 | 2009-04-30 17:32:17 +0000 | [diff] [blame] | 8 | |
| 9 | // <rdar://problem/6840045> |
| 10 | typedef char ueber_aligned_char __attribute__((aligned(8))); |
| 11 | |
| 12 | struct struct_with_ueber_char { |
| 13 | ueber_aligned_char c; |
| 14 | }; |
| 15 | |
John McCall | 4081a5c | 2010-10-08 18:24:19 +0000 | [diff] [blame] | 16 | char a = 0; |
Douglas Gregor | 1885764 | 2009-04-30 17:32:17 +0000 | [diff] [blame] | 17 | |
| 18 | char a0[__alignof__(ueber_aligned_char) == 8? 1 : -1] = { 0 }; |
| 19 | char a1[__alignof__(struct struct_with_ueber_char) == 8? 1 : -1] = { 0 }; |
John McCall | 4081a5c | 2010-10-08 18:24:19 +0000 | [diff] [blame] | 20 | char a2[__alignof__(a) == 1? : -1] = { 0 }; |
| 21 | char a3[sizeof(a) == 1? : -1] = { 0 }; |
| 22 | |
| 23 | // rdar://problem/8335865 |
| 24 | int b __attribute__((aligned(2))); |
| 25 | char b1[__alignof__(b) == 2 ?: -1] = {0}; |
| 26 | |
| 27 | struct C { int member __attribute__((aligned(2))); } c; |
| 28 | char c1[__alignof__(c) == 4 ?: -1] = {0}; |
| 29 | char c2[__alignof__(c.member) == 4 ?: -1] = {0}; |
| 30 | |
| 31 | struct D { int member __attribute__((aligned(2))) __attribute__((packed)); } d; |
| 32 | char d1[__alignof__(d) == 2 ?: -1] = {0}; |
| 33 | char d2[__alignof__(d.member) == 2 ?: -1] = {0}; |
| 34 | |
Douglas Gregor | b2749b1 | 2012-05-11 23:01:43 +0000 | [diff] [blame] | 35 | struct E { int member __attribute__((align(2))); } __attribute__((packed)); |
John McCall | 4081a5c | 2010-10-08 18:24:19 +0000 | [diff] [blame] | 36 | struct E e; |
| 37 | char e1[__alignof__(e) == 2 ?: -1] = {0}; |
| 38 | char e2[__alignof__(e.member) == 2 ?: -1] = {0}; |