1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
3 groupshared float a[10];
8 // expected-error@+1 {{automatic variable qualified with an address space}}
12 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
13 // expected-error@+1 {{return type cannot be qualified with address space}}
14 groupshared float foo() {
15 static groupshared float foo0;
18 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
19 // expected-error@+1 {{return type cannot be qualified with address space}}
20 groupshared void bar() {
21 extern groupshared float bar0;
23 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
24 // expected-error@+1 {{return type cannot be qualified with address space}}
25 groupshared float decl() {
30 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
31 // expected-error@+1 {{return type cannot be qualified with address space}}
32 groupshared void foo() {}
33 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
34 // expected-error@+1 {{return type cannot be qualified with address space}}
35 groupshared void bar();
36 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
37 // expected-error@+1 {{return type cannot be qualified with address space}}
38 friend groupshared void friend_def() {}
39 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
40 // expected-error@+1 {{return type cannot be qualified with address space}}
41 friend groupshared void friend_decl();
45 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
46 // expected-error@+1 {{field may not be qualified with an address space}}
48 static groupshared float g;
51 // expected-error@+1 {{parameter may not be qualified with an address space}}
52 float foo2(groupshared float a) {
56 // expected-note@+2 {{parameter may not be qualified with an address space}}
61 using GSF = groupshared float;
63 // expected-error@+1 {{no matching function for call to 'tfoo'}}
64 GSF gs2 = tfoo<GSF>(gs);
66 // NOTE:This one didn't report error on the groupshared return type,
67 // it is caused by return type check is after pointer check which is acceptable.
68 // expected-error@+1 {{pointers are unsupported in HLSL}}
69 groupshared void (*fp)();
70 // expected-error@+2 {{pointers are unsupported in HLSL}}
71 // expected-error@+1 {{parameter may not be qualified with an address space}}
72 void (*fp2)(groupshared float);
73 // NOTE: HLSL not support trailing return types.
74 // expected-warning@#func{{'auto' type specifier is a HLSL 202y extension}}
75 // expected-error@#func{{return type cannot be qualified with address space}}
76 auto func() -> groupshared void; // #func
77 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
78 // expected-error@+1 {{return type cannot be qualified with address space}}
82 // Do we reject it as a function qualifier on a member function?
86 // Does it impact size or alignment?
87 _Static_assert(sizeof(float) == sizeof(groupshared float), "");
88 _Static_assert(_Alignof(double) == _Alignof(groupshared double),"");
90 // Does it impact type identity for templates?
91 template <typename Ty>
93 static const bool value = false;
97 struct S3<groupshared float> {
98 static const bool value = true;
100 _Static_assert(!S3<float>::value, "");
101 _Static_assert(S3<groupshared float>::value, "");
103 // Can you overload based on the qualifier?
104 void func(float f) {}
105 // expected-error@+1 {{parameter may not be qualified with an address space}}
106 void func(groupshared float f) {}