forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattr-syclglobalvar.cpp
More file actions
55 lines (41 loc) · 2.47 KB
/
attr-syclglobalvar.cpp
File metadata and controls
55 lines (41 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only -isystem %S %s
#include <Inputs-isystem/attr-syclglobalvar.hpp>
#include "../Inputs/sycl.hpp"
__attribute__((sycl_global_var)) int GlobalWithAttribute;
__attribute__((sycl_global_var)) extern int ExternGlobalWithAttribute;
namespace NS {
__attribute__((sycl_global_var)) int NSGlobalWithAttribute;
}
struct S {
__attribute__((sycl_global_var)) static int StaticMember;
// expected-error@+1 {{attribute only applies to global variables}}
__attribute__((sycl_global_var)) int InstanceMember;
};
int S::StaticMember = 0;
__attribute__((sycl_global_var)) S GlobalStruct;
__attribute__((sycl_global_var)) static S StaticGlobal;
static union {
// expected-error@+1 {{attribute only applies to global variables}}
__attribute__((sycl_global_var)) int AnonymousStaticUnionInstanceMember;
};
// expected-error@+1 {{attribute takes no arguments}}
__attribute__((sycl_global_var(42))) int GlobalWithAttributeArg;
int GlobalNoAttribute;
// expected-error@+1 {{attribute only applies to global variables}}
__attribute__((sycl_global_var)) void F() {
// expected-error@+1 {{attribute only applies to global variables}}
__attribute__((sycl_global_var)) static int StaticLocalVar;
// expected-error@+1 {{attribute only applies to global variables}}
__attribute__((sycl_global_var)) int Local;
cl::sycl::kernel_single_task<class kernel_name>([=] () {
(void)GlobalWithAttribute; // expected-error {{SYCL kernel cannot use a non-const global variable}}
(void)ExternGlobalWithAttribute; // expected-error {{SYCL kernel cannot use a non-const global variable}}
(void)NS::NSGlobalWithAttribute; // expected-error {{SYCL kernel cannot use a non-const global variable}}
(void)S::StaticMember; // expected-error {{SYCL kernel cannot use a non-const global variable}}
(void)GlobalStruct.InstanceMember; // expected-error {{SYCL kernel cannot use a non-const global variable}}
(void)StaticGlobal.InstanceMember; // expected-error {{SYCL kernel cannot use a non-const static data variable}}
(void)StaticLocalVar; // expected-error {{SYCL kernel cannot use a non-const static data variable}}
(void)AnonymousStaticUnionInstanceMember; // expected-error {{SYCL kernel cannot use a non-const static data variable}}
(void)GlobalNoAttribute; // expected-error {{SYCL kernel cannot use a non-const global variable}} expected-note@../Inputs/sycl.hpp:* {{called by}}
});
}