Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Anders Carlsson | d8fe2d5 | 2009-11-07 06:07:58 +0000 | [diff] [blame] | 2 | template <typename T> |
| 3 | struct A { |
| 4 | char a __attribute__((aligned(16))); |
Douglas Gregor | a6b0907 | 2010-05-17 23:46:49 +0000 | [diff] [blame] | 5 | |
| 6 | struct B { |
| 7 | typedef T __attribute__((aligned(16))) i16; |
| 8 | i16 x; |
| 9 | }; |
Anders Carlsson | d8fe2d5 | 2009-11-07 06:07:58 +0000 | [diff] [blame] | 10 | }; |
| 11 | int a[sizeof(A<int>) == 16 ? 1 : -1]; |
Douglas Gregor | a6b0907 | 2010-05-17 23:46:49 +0000 | [diff] [blame] | 12 | int a2[sizeof(A<int>::B) == 16 ? 1 : -1]; |
Anders Carlsson | d8fe2d5 | 2009-11-07 06:07:58 +0000 | [diff] [blame] | 13 | |
John McCall | 1d8d1cc | 2010-08-01 02:01:53 +0000 | [diff] [blame] | 14 | // rdar://problem/8243419 |
| 15 | namespace test1 { |
| 16 | template <typename T> struct A { |
| 17 | int a; |
| 18 | T b[0]; |
| 19 | } __attribute__((packed)); |
| 20 | |
| 21 | typedef A<unsigned long> type; |
| 22 | |
| 23 | int test0[sizeof(type) == 4 ? 1 : -1]; |
| 24 | int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1]; |
| 25 | int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1]; |
| 26 | } |