Skip to content

[HLSL] Align language modes on 202x as default #108662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions clang/include/clang/Basic/LangStandards.def
Original file line number Diff line number Diff line change
Expand Up @@ -230,27 +230,27 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
// HLSL
LANGSTANDARD(hlsl, "hlsl",
HLSL, "High Level Shader Language",
LineComment | HLSL | CPlusPlus )
LineComment | HLSL | CPlusPlus | CPlusPlus11)

LANGSTANDARD(hlsl2015, "hlsl2015",
HLSL, "High Level Shader Language 2015",
LineComment | HLSL | CPlusPlus )
LineComment | HLSL | CPlusPlus | CPlusPlus11)

LANGSTANDARD(hlsl2016, "hlsl2016",
HLSL, "High Level Shader Language 2016",
LineComment | HLSL | CPlusPlus )
LineComment | HLSL | CPlusPlus | CPlusPlus11)

LANGSTANDARD(hlsl2017, "hlsl2017",
HLSL, "High Level Shader Language 2017",
LineComment | HLSL | CPlusPlus )
LineComment | HLSL | CPlusPlus | CPlusPlus11)

LANGSTANDARD(hlsl2018, "hlsl2018",
HLSL, "High Level Shader Language 2018",
LineComment | HLSL | CPlusPlus )
LineComment | HLSL | CPlusPlus | CPlusPlus11)

LANGSTANDARD(hlsl2021, "hlsl2021",
HLSL, "High Level Shader Language 2021",
LineComment | HLSL | CPlusPlus )
LineComment | HLSL | CPlusPlus | CPlusPlus11)

LANGSTANDARD(hlsl202x, "hlsl202x",
HLSL, "High Level Shader Language 202x",
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Basic/LangStandards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
case Language::RenderScript:
return LangStandard::lang_c99;
case Language::HLSL:
return LangStandard::lang_hlsl2021;
return LangStandard::lang_hlsl202x;
}
llvm_unreachable("unhandled Language kind!");
}
2 changes: 1 addition & 1 deletion clang/test/Preprocessor/predefined-macros-hlsl.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// HALF: #define __HLSL_ENABLE_16_BIT 1
// NOHALF-NOT: __HLSL_ENABLE_16_BIT

// CHECK: #define __HLSL_VERSION 2021
// CHECK: #define __HLSL_VERSION 2028
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2028 == 202x and 2029 == 202y I expect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. Subject to revision once we have an actual year.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand where this 2028 is coming from. Is 202x intended to be 2028?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

202x doesn't have a year yet, so to make it big and far out I gave it 2028 and 202y has 2029... these will change before we actually ship.


// CHECK: #define __SHADER_STAGE_AMPLIFICATION 14
// CHECK: #define __SHADER_STAGE_COMPUTE 5
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ RWBuffer<> BufferErr2;

[numthreads(1,1,1)]
void main() {
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer<vector<float, 3> >'}}
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer<vector<float, 3>>'}}
// expected-note@* {{implicitly declared private here}}
}
2 changes: 1 addition & 1 deletion clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ StructuredBuffer<> BufferErr2;

[numthreads(1,1,1)]
void main() {
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::StructuredBuffer<vector<float, 3> >'}}
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::StructuredBuffer<vector<float, 3>>'}}
// expected-note@* {{implicitly declared private here}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _Static_assert(is_same<__decltype(4294967296), int64_t>::value, "4294967296 is i
// Clang emits a warning that it is interpreting it as unsigned because that is
// not conforming to the C standard.

// expected-warning@+1{{integer literal is too large to be represented in type 'long' and is subject to undefined behavior under C++98, interpreting as 'unsigned long'; this literal will be ill-formed in C++11 onwards}}
// expected-warning@+1{{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all good now, but even though the filename suggests it's relevant to 202x, it wasn't targeting that before. Perhaps that contributed to the need for this change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is verifying that Clang implements the 202x conforming literals feature. Clang doesn't implement the legacy behavior, so it is really the only behavior in Clang.

static const uint64_t V = 9223372036854775808;

_Static_assert(is_same<__decltype(0x0), int>::value, "0x0 is int");
Expand Down
3 changes: 2 additions & 1 deletion clang/test/SemaHLSL/Types/Traits/IsIntangibleTypeErrors.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
struct Undefined; // expected-note {{forward declaration of 'Undefined'}}
_Static_assert(!__builtin_hlsl_is_intangible(Undefined), ""); // expected-error{{incomplete type 'Undefined' used in type trait expression}}

void fn(int X) {
void fn(int X) { // expected-note {{declared here}}
// expected-error@#vla {{variable length arrays are not supported for the current target}}
// expected-error@#vla {{variable length arrays are not supported in '__builtin_hlsl_is_intangible'}}
// expected-warning@#vla {{variable length arrays in C++ are a Clang extension}}
// expected-note@#vla {{function parameter 'X' with unknown value cannot be used in a constant expression}}
_Static_assert(!__builtin_hlsl_is_intangible(int[X]), ""); // #vla
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s

// Some things that don't work!

Expand All @@ -14,11 +14,12 @@ _Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(Undefined, Defined

// Case 2: No variable length arrays!

void fn(int X) {
void fn(int X) { // expected-note{{declared here}}
// expected-error@#vla {{variable length arrays are not supported for the current target}}
// expected-error@#vla {{variable length arrays are not supported in '__builtin_hlsl_is_scalarized_layout_compatible'}}
// expected-error@#vla {{static assertion failed due to requirement '__builtin_hlsl_is_scalarized_layout_compatible(int[4], int[X])'}}
// expected-warning@#vla {{variable length arrays in C++ are a Clang extension}}
// expected-note@#vla{{function parameter 'X' with unknown value cannot be used in a constant expression}}
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(int[4], int[X]), ""); // #vla
}

Expand Down
4 changes: 1 addition & 3 deletions clang/test/SemaHLSL/group_shared.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ template<typename T>
T tfoo(T t) {
return t;
}
// expected-warning@+1 {{alias declarations are a C++11 extension}}
using GSF = groupshared float;
GSF gs;
// expected-error@+1 {{no matching function for call to 'tfoo'}}
Expand All @@ -73,8 +72,7 @@ groupshared void (*fp)();
void (*fp2)(groupshared float);
// NOTE: HLSL not support trailing return types.
// expected-warning@#func{{'auto' type specifier is a HLSL 202y extension}}
// expected-warning@#func {{'auto' type specifier is a C++11 extension}}
// expected-error@#func {{expected function body after function declarator}}
// 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}}
Expand Down
1 change: 0 additions & 1 deletion clang/test/SemaHLSL/prohibit_reference.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
int& bark(int); // expected-error {{references are unsupported in HLSL}}
void meow(int&); // expected-error {{references are unsupported in HLSL}}
void chirp(int &&); // expected-error {{references are unsupported in HLSL}}
// expected-warning@-1 {{rvalue references are a C++11 extension}}

struct Foo {
int X;
Expand Down
Loading