[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaSYCL / special-class-attribute.cpp
blob1bfe7cc5b96c255f277424b46989461eb7064781
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
3 // No diagnostics
4 class [[clang::sycl_special_class]] class1 {
5 void __init(){}
6 };
7 class __attribute__((sycl_special_class)) class2 {
8 void __init(){}
9 };
11 class class3;
12 class [[clang::sycl_special_class]] class3 {
13 void __init(){}
16 class class4;
17 class __attribute__((sycl_special_class)) class4 {
18 void __init(){}
21 struct [[clang::sycl_special_class]] struct1 {
22 void __init(){}
24 struct __attribute__((sycl_special_class)) struct2 {
25 void __init(){}
28 class __attribute__((sycl_special_class)) class5;
29 class class5 {
30 void __init(){}
33 struct __attribute__((sycl_special_class)) struct6 {
34 struct6();
35 bool operator==(const struct6 &);
36 struct6 &operator()();
37 ~struct6();
38 void __init(){}
41 // Must have one and only one __init method defined
42 class __attribute__((sycl_special_class)) class6 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
43 class6() {}
45 class [[clang::sycl_special_class]] class7 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
46 void __init();
49 class [[clang::sycl_special_class]] class8 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
50 void __init();
51 int func() {}
52 void __init(int a){}
55 struct __attribute__((sycl_special_class)) struct3;
56 struct struct3 {}; // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
58 // expected-error@+1{{'sycl_special_class' attribute must have one and only one '__init' method defined}}
59 struct __attribute__((sycl_special_class)) struct7 {
60 struct7();
61 bool operator==(const struct7 &);
62 struct7 &operator()();
63 ~struct7();
66 // Only classes
67 [[clang::sycl_special_class]] int var1 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
68 __attribute__((sycl_special_class)) int var2 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
70 [[clang::sycl_special_class]] void foo1(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
71 __attribute__((sycl_special_class)) void foo2(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
73 // Attribute takes no arguments
74 class [[clang::sycl_special_class(1)]] class9{}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
75 class __attribute__((sycl_special_class(1))) class10 {}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
77 // __init method must be defined inside the CXXRecordDecl.
78 class [[clang::sycl_special_class]] class11 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
79 void __init();
81 void class11::__init(){}
83 class __attribute__((sycl_special_class)) class12 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
84 void __init();
86 void class12::__init(){}
88 struct [[clang::sycl_special_class]] struct4 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
89 void __init();
91 void struct4::__init(){}
93 struct __attribute__((sycl_special_class)) struct5 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}}
94 void __init();
96 void struct5::__init(){}