brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 0293ddd Raw
107 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify2 3 groupshared float a[10];4 5 [numthreads(8,8,1)]6 void main() {7   a[0] = 1;8   // expected-error@+1 {{automatic variable qualified with an address space}}9   groupshared float b;10 }11 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;16    return 1;17 }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;22  }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() {26      return 1;27  }28 29  class C {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();42  };43 44  struct S {45    // expected-warning@+2 {{'groupshared' attribute only applies to variables}}46    // expected-error@+1 {{field may not be qualified with an address space}}47    groupshared float f;48    static groupshared float g;49  };50 51  // expected-error@+1 {{parameter may not be qualified with an address space}}52  float foo2(groupshared float a) {53    return a;54  }55 56// expected-note@+2 {{parameter may not be qualified with an address space}}57template<typename T>58  T tfoo(T t) {59     return t;60  }61 using GSF = groupshared float;62 GSF gs;63 // expected-error@+1 {{no matching function for call to 'tfoo'}}64 GSF gs2 = tfoo<GSF>(gs);65 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}}69groupshared void (*fp)();70// expected-error@+2 {{pointers are unsupported in HLSL}}71// expected-error@+1 {{parameter may not be qualified with an address space}}72void (*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}}76auto func() -> groupshared void; // #func77// expected-warning@+2 {{'groupshared' attribute only applies to variables}}78// expected-error@+1 {{return type cannot be qualified with address space}}79void groupshared f();80 81struct S2 {82  // Do we reject it as a function qualifier on a member function?83  void f() groupshared;84};85 86// Does it impact size or alignment?87_Static_assert(sizeof(float) == sizeof(groupshared float), "");88_Static_assert(_Alignof(double) == _Alignof(groupshared double),"");89 90// Does it impact type identity for templates?91template <typename Ty>92struct S3 {93  static const bool value = false;94};95 96template <>97struct S3<groupshared float> {98  static const bool value = true;99};100_Static_assert(!S3<float>::value, "");101_Static_assert(S3<groupshared float>::value, "");102 103// Can you overload based on the qualifier?104void func(float f) {}105// expected-error@+1 {{parameter may not be qualified with an address space}}106void func(groupshared float f) {}107