xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-attr.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc template <typename T>
4*f4a2713aSLionel Sambuc struct A {
5*f4a2713aSLionel Sambuc   char a __attribute__((aligned(16)));
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc   struct B {
8*f4a2713aSLionel Sambuc     typedef T __attribute__((aligned(16))) i16;
9*f4a2713aSLionel Sambuc     i16 x;
10*f4a2713aSLionel Sambuc   };
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc int a[sizeof(A<int>) == 16 ? 1 : -1];
13*f4a2713aSLionel Sambuc int a2[sizeof(A<int>::B) == 16 ? 1 : -1];
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // rdar://problem/8243419
16*f4a2713aSLionel Sambuc namespace test1 {
17*f4a2713aSLionel Sambuc   template <typename T> struct A {
18*f4a2713aSLionel Sambuc     int a;
19*f4a2713aSLionel Sambuc     T b[0];
20*f4a2713aSLionel Sambuc   } __attribute__((packed));
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc   typedef A<unsigned long> type;
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   int test0[sizeof(type) == 4 ? 1 : -1];
25*f4a2713aSLionel Sambuc   int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1];
26*f4a2713aSLionel Sambuc   int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1];
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc namespace test2 {
30*f4a2713aSLionel Sambuc   template <class type>
31*f4a2713aSLionel Sambuc   struct fastscriptmember {
32*f4a2713aSLionel Sambuc       type Member __attribute__ ((packed));
33*f4a2713aSLionel Sambuc       char x;
34*f4a2713aSLionel Sambuc   };
35*f4a2713aSLionel Sambuc   int test0[sizeof(fastscriptmember<int>) == 5 ? 1 : -1];
36*f4a2713aSLionel Sambuc }
37