Files
TheRock/compiler/amd-llvm/clang/test/SemaHLSL/group_shared.hlsl
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

101 lines
3.7 KiB
HLSL

// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -fexperimental-new-constant-interpreter -verify
groupshared float a[10];
[numthreads(8,8,1)]
void main() {
a[0] = 1;
// expected-error@+1 {{automatic variable qualified with an address space}}
groupshared float b;
}
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
groupshared float foo() {
static groupshared float foo0;
return 1;
}
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
groupshared void bar() {
extern groupshared float bar0;
}
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
groupshared float decl() {
return 1;
}
class C {
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
groupshared void foo() {}
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
groupshared void bar();
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
friend groupshared void friend_def() {}
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
friend groupshared void friend_decl();
};
struct S {
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{field may not be qualified with an address space}}
groupshared float f;
static groupshared float g;
};
// expected-note@+2 {{candidate template ignored: substitution failure [with T = GSF]}}
template<typename T>
T tfoo(T t) {
return t;
}
using GSF = groupshared float;
GSF gs;
// expected-error@+1 {{no matching function for call to 'tfoo'}}
GSF gs2 = tfoo<GSF>(gs);
// NOTE:This one didn't report error on the groupshared return type,
// it is caused by return type check is after pointer check which is acceptable.
// expected-error@+1 {{pointers are unsupported in HLSL}}
groupshared void (*fp)();
// expected-error@+1 {{pointers are unsupported in HLSL}}
void (*fp2)(groupshared float);
// NOTE: HLSL not support trailing return types.
// expected-warning@#func{{'auto' type specifier is a HLSL 202y extension}}
// expected-error@#func{{return type cannot be qualified with address space}}
auto func() -> groupshared void; // #func
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
void groupshared f();
struct S2 {
// Do we reject it as a function qualifier on a member function?
void f() groupshared;
};
// Does it impact size or alignment?
_Static_assert(sizeof(float) == sizeof(groupshared float), "");
_Static_assert(_Alignof(double) == _Alignof(groupshared double),"");
// Does it impact type identity for templates?
template <typename Ty>
struct S3 {
static const bool value = false;
};
template <>
struct S3<groupshared float> {
static const bool value = true;
};
_Static_assert(!S3<float>::value, "");
_Static_assert(S3<groupshared float>::value, "");
// Can you overload based on the qualifier?
void func(float f) {}
void func(groupshared float f) {}