Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGenCUDA / Inputs / cuda-initializers.h
blob186b160276512e5427e14a0f5ebfa05808a5a789
1 // CUDA struct types with interesting initialization properties.
2 // Keep in sync with ../SemaCUDA/Inputs/cuda-initializers.h.
4 // Base classes with different initializer variants.
6 // trivial constructor -- allowed
7 struct T {
8 int t;
9 };
11 // empty constructor
12 struct EC {
13 int ec;
14 __device__ EC() {} // -- allowed
15 __device__ EC(int) {} // -- not allowed
18 // empty destructor
19 struct ED {
20 __device__ ~ED() {} // -- allowed
23 struct ECD {
24 __device__ ECD() {} // -- allowed
25 __device__ ~ECD() {} // -- allowed
28 // empty templated constructor -- allowed with no arguments
29 struct ETC {
30 template <typename... T> __device__ ETC(T...) {}
33 // undefined constructor -- not allowed
34 struct UC {
35 int uc;
36 __device__ UC();
39 // undefined destructor -- not allowed
40 struct UD {
41 int ud;
42 __device__ ~UD();
45 // empty constructor w/ initializer list -- not allowed
46 struct ECI {
47 int eci;
48 __device__ ECI() : eci(1) {}
51 // non-empty constructor -- not allowed
52 struct NEC {
53 int nec;
54 __device__ NEC() { nec = 1; }
57 // non-empty destructor -- not allowed
58 struct NED {
59 int ned;
60 __device__ ~NED() { ned = 1; }
63 // no-constructor, virtual method -- not allowed
64 struct NCV {
65 int ncv;
66 __device__ virtual void vm() {}
69 // virtual destructor -- not allowed.
70 struct VD {
71 __device__ virtual ~VD() {}
74 // dynamic in-class field initializer -- not allowed
75 __device__ int f();
76 struct NCF {
77 int ncf = f();
80 // static in-class field initializer. NVCC does not allow it, but
81 // clang generates static initializer for this, so we'll accept it.
82 // We still can't use it on __shared__ vars as they don't allow *any*
83 // initializers.
84 struct NCFS {
85 int ncfs = 3;
88 // undefined templated constructor -- not allowed
89 struct UTC {
90 template <typename... T> __device__ UTC(T...);
93 // non-empty templated constructor -- not allowed
94 struct NETC {
95 int netc;
96 template <typename... T> __device__ NETC(T...) { netc = 1; }
99 // Regular base class -- allowed
100 struct T_B_T : T {};
102 // Incapsulated object of allowed class -- allowed
103 struct T_F_T {
104 T t;
107 // array of allowed objects -- allowed
108 struct T_FA_T {
109 T t[2];
113 // Calling empty base class initializer is OK
114 struct EC_I_EC : EC {
115 __device__ EC_I_EC() : EC() {}
118 // .. though passing arguments is not allowed.
119 struct EC_I_EC1 : EC {
120 __device__ EC_I_EC1() : EC(1) {}
123 // Virtual base class -- not allowed
124 struct T_V_T : virtual T {};
126 // Inherited from or incapsulated class with non-empty constructor --
127 // not allowed
128 struct T_B_NEC : NEC {};
129 struct T_F_NEC {
130 NEC nec;
132 struct T_FA_NEC {
133 NEC nec[2];
137 // Inherited from or incapsulated class with non-empty desstructor --
138 // not allowed
139 struct T_B_NED : NED {};
140 struct T_F_NED {
141 NED ned;
143 struct T_FA_NED {
144 NED ned[2];