58 lines · plain
1// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify %s2// RUN: %clang_cc1 -isystem %S/Inputs -fcuda-is-device -fsyntax-only -verify %s3 4#include <cuda.h>5 6// Check trivial ctor/dtor7struct A {8 int x;9 A() {}10 ~A() {}11};12 13__device__ A a;14 15// Check trivial ctor/dtor of template class16template<typename T>17struct TA {18 T x;19 TA() {}20 ~TA() {}21};22 23__device__ TA<int> ta;24 25// Check non-trivial ctor/dtor in parent template class26template<typename T>27struct TB {28 T x;29 TB() { static int nontrivial_ctor = 1; }30 ~TB() {}31};32 33template<typename T>34struct TC : TB<T> {35 T x;36 TC() {}37 ~TC() {}38};39 40template class TC<int>;41 42__device__ TC<int> tc; //expected-error {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}43 44// Check trivial ctor specialization45template <typename T>46struct C {47 explicit C() {};48};49 50template <> C<int>::C() {};51__device__ C<int> ci_d;52C<int> ci_h;53 54// Check non-trivial ctor specialization55template <> C<float>::C() { static int nontrivial_ctor = 1; }56__device__ C<float> cf_d; //expected-error {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}57C<float> cf_h;58