Skip to content

Commit 4886403

Browse files
authored
[HLSL] Align language modes on 202x as default (#108662)
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
1 parent dbc5900 commit 4886403

File tree

10 files changed

+17
-18
lines changed

10 files changed

+17
-18
lines changed

clang/include/clang/Basic/LangStandards.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,27 @@ LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
230230
// HLSL
231231
LANGSTANDARD(hlsl, "hlsl",
232232
HLSL, "High Level Shader Language",
233-
LineComment | HLSL | CPlusPlus )
233+
LineComment | HLSL | CPlusPlus | CPlusPlus11)
234234

235235
LANGSTANDARD(hlsl2015, "hlsl2015",
236236
HLSL, "High Level Shader Language 2015",
237-
LineComment | HLSL | CPlusPlus )
237+
LineComment | HLSL | CPlusPlus | CPlusPlus11)
238238

239239
LANGSTANDARD(hlsl2016, "hlsl2016",
240240
HLSL, "High Level Shader Language 2016",
241-
LineComment | HLSL | CPlusPlus )
241+
LineComment | HLSL | CPlusPlus | CPlusPlus11)
242242

243243
LANGSTANDARD(hlsl2017, "hlsl2017",
244244
HLSL, "High Level Shader Language 2017",
245-
LineComment | HLSL | CPlusPlus )
245+
LineComment | HLSL | CPlusPlus | CPlusPlus11)
246246

247247
LANGSTANDARD(hlsl2018, "hlsl2018",
248248
HLSL, "High Level Shader Language 2018",
249-
LineComment | HLSL | CPlusPlus )
249+
LineComment | HLSL | CPlusPlus | CPlusPlus11)
250250

251251
LANGSTANDARD(hlsl2021, "hlsl2021",
252252
HLSL, "High Level Shader Language 2021",
253-
LineComment | HLSL | CPlusPlus )
253+
LineComment | HLSL | CPlusPlus | CPlusPlus11)
254254

255255
LANGSTANDARD(hlsl202x, "hlsl202x",
256256
HLSL, "High Level Shader Language 202x",

clang/lib/Basic/LangStandards.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
117117
case Language::RenderScript:
118118
return LangStandard::lang_c99;
119119
case Language::HLSL:
120-
return LangStandard::lang_hlsl2021;
120+
return LangStandard::lang_hlsl202x;
121121
}
122122
llvm_unreachable("unhandled Language kind!");
123123
}

clang/test/Preprocessor/predefined-macros-hlsl.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// HALF: #define __HLSL_ENABLE_16_BIT 1
1313
// NOHALF-NOT: __HLSL_ENABLE_16_BIT
1414

15-
// CHECK: #define __HLSL_VERSION 2021
15+
// CHECK: #define __HLSL_VERSION 2028
1616

1717
// CHECK: #define __SHADER_STAGE_AMPLIFICATION 14
1818
// CHECK: #define __SHADER_STAGE_COMPUTE 5

clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ RWBuffer<> BufferErr2;
1414

1515
[numthreads(1,1,1)]
1616
void main() {
17-
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer<vector<float, 3> >'}}
17+
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer<vector<float, 3>>'}}
1818
// expected-note@* {{implicitly declared private here}}
1919
}

clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ StructuredBuffer<> BufferErr2;
1414

1515
[numthreads(1,1,1)]
1616
void main() {
17-
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::StructuredBuffer<vector<float, 3> >'}}
17+
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::StructuredBuffer<vector<float, 3>>'}}
1818
// expected-note@* {{implicitly declared private here}}
1919
}

clang/test/SemaHLSL/Types/Arithmetic/literal_suffixes_202x.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _Static_assert(is_same<__decltype(4294967296), int64_t>::value, "4294967296 is i
3737
// Clang emits a warning that it is interpreting it as unsigned because that is
3838
// not conforming to the C standard.
3939

40-
// 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}}
40+
// expected-warning@+1{{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
4141
static const uint64_t V = 9223372036854775808;
4242

4343
_Static_assert(is_same<__decltype(0x0), int>::value, "0x0 is int");

clang/test/SemaHLSL/Types/Traits/IsIntangibleTypeErrors.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
struct Undefined; // expected-note {{forward declaration of 'Undefined'}}
44
_Static_assert(!__builtin_hlsl_is_intangible(Undefined), ""); // expected-error{{incomplete type 'Undefined' used in type trait expression}}
55

6-
void fn(int X) {
6+
void fn(int X) { // expected-note {{declared here}}
77
// expected-error@#vla {{variable length arrays are not supported for the current target}}
88
// expected-error@#vla {{variable length arrays are not supported in '__builtin_hlsl_is_intangible'}}
99
// expected-warning@#vla {{variable length arrays in C++ are a Clang extension}}
10+
// expected-note@#vla {{function parameter 'X' with unknown value cannot be used in a constant expression}}
1011
_Static_assert(!__builtin_hlsl_is_intangible(int[X]), ""); // #vla
1112
}

clang/test/SemaHLSL/Types/Traits/ScalarizedLayoutCompatibleErrors.hlsl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s
22

33
// Some things that don't work!
44

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

1515
// Case 2: No variable length arrays!
1616

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

clang/test/SemaHLSL/group_shared.hlsl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ template<typename T>
5858
T tfoo(T t) {
5959
return t;
6060
}
61-
// expected-warning@+1 {{alias declarations are a C++11 extension}}
6261
using GSF = groupshared float;
6362
GSF gs;
6463
// expected-error@+1 {{no matching function for call to 'tfoo'}}
@@ -73,8 +72,7 @@ groupshared void (*fp)();
7372
void (*fp2)(groupshared float);
7473
// NOTE: HLSL not support trailing return types.
7574
// expected-warning@#func{{'auto' type specifier is a HLSL 202y extension}}
76-
// expected-warning@#func {{'auto' type specifier is a C++11 extension}}
77-
// expected-error@#func {{expected function body after function declarator}}
75+
// expected-error@#func{{return type cannot be qualified with address space}}
7876
auto func() -> groupshared void; // #func
7977
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
8078
// expected-error@+1 {{return type cannot be qualified with address space}}

clang/test/SemaHLSL/prohibit_reference.hlsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
int& bark(int); // expected-error {{references are unsupported in HLSL}}
44
void meow(int&); // expected-error {{references are unsupported in HLSL}}
55
void chirp(int &&); // expected-error {{references are unsupported in HLSL}}
6-
// expected-warning@-1 {{rvalue references are a C++11 extension}}
76

87
struct Foo {
98
int X;

0 commit comments

Comments
 (0)