-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] Allow narrowing in initialization lists #108035
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
Conversation
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 llvm#56067
@llvm/pr-subscribers-hlsl @llvm/pr-subscribers-clang Author: Chris B (llvm-beanz) ChangesHLSL'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 Full diff: https://github.com/llvm/llvm-project/pull/108035.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7dc17187524621..8a32114a1ab313 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -9537,7 +9537,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)));
|
Can we test this? |
It is tested. The modified test case adds a run line with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine. Curious, why is this extra RUN: line added? Doesn't the other one already contain the same parameters -ast-dump -o - %s | FileCheck %s
?
RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -ast-dump -o - %s | FileCheck %s
The diff is a bit awkward to read, but the second run line adds |
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