[clang] 6eb3519 - [HLSL] Allow narrowing in initialization lists (#108035)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 10:03:29 PDT 2024
Author: Chris B
Date: 2024-09-12T12:03:25-05:00
New Revision: 6eb3519fd70bb50bc3773fdf0bf9435dae2abfe7
URL: https://github.com/llvm/llvm-project/commit/6eb3519fd70bb50bc3773fdf0bf9435dae2abfe7
DIFF: https://github.com/llvm/llvm-project/commit/6eb3519fd70bb50bc3773fdf0bf9435dae2abfe7.diff
LOG: [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
Added:
Modified:
clang/lib/Sema/SemaInit.cpp
clang/test/AST/HLSL/vector-constructors.hlsl
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index d21b8cb8c04e63..4d11f2a43fcc6b 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -9548,7 +9548,7 @@ static void DiagnoseNarrowingInInitList(Sema &S,
unsigned ConstRefDiagID, unsigned WarnDiagID) {
unsigned DiagID;
auto &L = S.getLangOpts();
- if (L.CPlusPlus11 &&
+ if (L.CPlusPlus11 && !L.HLSL &&
(!L.MicrosoftExt || L.isCompatibleWithMSVC(LangOptions::MSVC2015)))
DiagID = IsConstRef ? ConstRefDiagID : DefaultDiagID;
else
diff --git a/clang/test/AST/HLSL/vector-constructors.hlsl b/clang/test/AST/HLSL/vector-constructors.hlsl
index 905f11d9223248..9161ad110df1f1 100644
--- a/clang/test/AST/HLSL/vector-constructors.hlsl
+++ b/clang/test/AST/HLSL/vector-constructors.hlsl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -ast-dump -o - %s | FileCheck %s
typedef float float2 __attribute__((ext_vector_type(2)));
typedef float float3 __attribute__((ext_vector_type(3)));
More information about the cfe-commits
mailing list