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