blob: bbadb6375b5b9ae508598ed61aa9af03176970d6 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Anders Carlssond8fe2d52009-11-07 06:07:58 +00002template <typename T>
3struct A {
4 char a __attribute__((aligned(16)));
Douglas Gregora6b09072010-05-17 23:46:49 +00005
6 struct B {
7 typedef T __attribute__((aligned(16))) i16;
8 i16 x;
9 };
Anders Carlssond8fe2d52009-11-07 06:07:58 +000010};
11int a[sizeof(A<int>) == 16 ? 1 : -1];
Douglas Gregora6b09072010-05-17 23:46:49 +000012int a2[sizeof(A<int>::B) == 16 ? 1 : -1];
Anders Carlssond8fe2d52009-11-07 06:07:58 +000013
John McCall1d8d1cc2010-08-01 02:01:53 +000014// rdar://problem/8243419
15namespace 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}