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 // expected-warning@+1 {{alias declarations are a C++11 extension}}
62 using GSF = groupshared float;
64 // expected-error@+1 {{no matching function for call to 'tfoo'}}
65 GSF gs2 = tfoo<GSF>(gs);
67 // NOTE:This one didn't report error on the groupshared return type,
68 // it is caused by return type check is after pointer check which is acceptable.
69 // expected-error@+1 {{pointers are unsupported in HLSL}}
70 groupshared void (*fp)();
71 // expected-error@+2 {{pointers are unsupported in HLSL}}
72 // expected-error@+1 {{parameter may not be qualified with an address space}}
73 void (*fp2)(groupshared float);
74 // NOTE: HLSL not support trailing return types.
75 // expected-warning@+2 {{'auto' type specifier is a C++11 extension}}
76 // expected-error@+1 {{expected function body after function declarator}}
77 auto func() -> groupshared void;
78 // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
79 // expected-error@+1 {{return type cannot be qualified with address space}}
83 // Do we reject it as a function qualifier on a member function?
87 // Does it impact size or alignment?
88 _Static_assert(sizeof(float) == sizeof(groupshared float), "");
89 _Static_assert(_Alignof(double) == _Alignof(groupshared double),"");
91 // Does it impact type identity for templates?
92 template <typename Ty>
94 static const bool value = false;
98 struct S3<groupshared float> {
99 static const bool value = true;
101 _Static_assert(!S3<float>::value, "");
102 _Static_assert(S3<groupshared float>::value, "");
104 // Can you overload based on the qualifier?
105 void func(float f) {}
106 // expected-error@+1 {{parameter may not be qualified with an address space}}
107 void func(groupshared float f) {}