Skip to content

Commit 6eb3519

Browse files
authored
[HLSL] Allow narrowing in initialization lists (#108035)
HLSL's initialization lists are _extremely_ generous about allowing conversions. This change demotes the C++11 warning to the legacy warning when in HLSL mode. Required for #56067
1 parent ab96409 commit 6eb3519

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/Sema/SemaInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9548,7 +9548,7 @@ static void DiagnoseNarrowingInInitList(Sema &S,
95489548
unsigned ConstRefDiagID, unsigned WarnDiagID) {
95499549
unsigned DiagID;
95509550
auto &L = S.getLangOpts();
9551-
if (L.CPlusPlus11 &&
9551+
if (L.CPlusPlus11 && !L.HLSL &&
95529552
(!L.MicrosoftExt || L.isCompatibleWithMSVC(LangOptions::MSVC2015)))
95539553
DiagID = IsConstRef ? ConstRefDiagID : DefaultDiagID;
95549554
else

clang/test/AST/HLSL/vector-constructors.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -ast-dump -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -ast-dump -o - %s | FileCheck %s
23

34
typedef float float2 __attribute__((ext_vector_type(2)));
45
typedef float float3 __attribute__((ext_vector_type(3)));

0 commit comments

Comments
 (0)