mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 13:16:49 +00:00

As captured in issue #108044, HLSL 202x is the target language mode for conformance for Clang. Earlier language modes will be a best effort and prioritized after 2020x. To make this easier and reduce our testing complexity we want to make 202x the default language mode now, and align all earlier modes to match 202x (except where we explicitly deviate). This change has the following concrete changes: * All older language modes gain `CPlusPlus11` as a base * The default language mode for HLSL sources is changed to 202x * A few test cases are updated to resolve differences in generated diagnostics. Second to last change for #108044
107 lines
3.9 KiB
HLSL
107 lines
3.9 KiB
HLSL
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -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-error@+1 {{parameter may not be qualified with an address space}}
|
|
float foo2(groupshared float a) {
|
|
return a;
|
|
}
|
|
|
|
// expected-note@+2 {{parameter may not be qualified with an address space}}
|
|
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@+2 {{pointers are unsupported in HLSL}}
|
|
// expected-error@+1 {{parameter may not be qualified with an address space}}
|
|
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) {}
|
|
// expected-error@+1 {{parameter may not be qualified with an address space}}
|
|
void func(groupshared float f) {}
|