blob: 1e94614f371daa9415f99e37dafbe579185df215 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Andy Gibbs8e8fb3b2012-10-19 12:44:48 +00002// expected-no-diagnostics
Anders Carlssond8fe2d52009-11-07 06:07:58 +00003template <typename T>
4struct A {
5 char a __attribute__((aligned(16)));
Douglas Gregora6b09072010-05-17 23:46:49 +00006
7 struct B {
8 typedef T __attribute__((aligned(16))) i16;
9 i16 x;
10 };
Anders Carlssond8fe2d52009-11-07 06:07:58 +000011};
12int a[sizeof(A<int>) == 16 ? 1 : -1];
Douglas Gregora6b09072010-05-17 23:46:49 +000013int a2[sizeof(A<int>::B) == 16 ? 1 : -1];
Anders Carlssond8fe2d52009-11-07 06:07:58 +000014
John McCall1d8d1cc2010-08-01 02:01:53 +000015// rdar://problem/8243419
16namespace test1 {
17 template <typename T> struct A {
18 int a;
19 T b[0];
20 } __attribute__((packed));
21
22 typedef A<unsigned long> type;
23
24 int test0[sizeof(type) == 4 ? 1 : -1];
25 int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1];
26 int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1];
27}
Eli Friedmanb68ec6b2012-11-07 00:35:20 +000028
29namespace test2 {
30 template <class type>
31 struct fastscriptmember {
32 type Member __attribute__ ((packed));
33 char x;
34 };
35 int test0[sizeof(fastscriptmember<int>) == 5 ? 1 : -1];
36}