Skip to content

Commit bf481f3

Browse files
author
git apple-llvm automerger
committed
Merge commit '52e0337ea341' from llvm.org/main into next
2 parents 754b015 + 52e0337 commit bf481f3

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

clang/lib/Sema/SemaChecking.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -11489,6 +11489,14 @@ static void AnalyzeAssignment(Sema &S, BinaryOperator *E) {
1148911489
static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,
1149011490
SourceLocation CContext, unsigned diag,
1149111491
bool pruneControlFlow = false) {
11492+
// For languages like HLSL and OpenCL, implicit conversion diagnostics listing
11493+
// address space annotations isn't really useful. The warnings aren't because
11494+
// you're converting a `private int` to `unsigned int`, it is because you're
11495+
// conerting `int` to `unsigned int`.
11496+
if (SourceType.hasAddressSpace())
11497+
SourceType = S.getASTContext().removeAddrSpaceQualType(SourceType);
11498+
if (T.hasAddressSpace())
11499+
T = S.getASTContext().removeAddrSpaceQualType(T);
1149211500
if (pruneControlFlow) {
1149311501
S.DiagRuntimeBehavior(E->getExprLoc(), E,
1149411502
S.PDiag(diag)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -Wconversion -fnative-half-type %s -verify
2+
3+
static double D = 2.0;
4+
static int I = D; // expected-warning{{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
5+
groupshared float F = I; // expected-warning{{implicit conversion from 'int' to 'float' may lose precision}}
6+
7+
export void fn() {
8+
half d = I; // expected-warning{{implicit conversion from 'int' to 'half' may lose precision}}
9+
int i = D; // expected-warning{{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
10+
int j = F; // expected-warning{{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
11+
int k = d; // expected-warning{{implicit conversion turns floating-point number into integer: 'half' to 'int'}}
12+
}

clang/test/SemaOpenCL/cl20-device-side-enqueue.cl

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ kernel void enqueue_kernel_tests(void) {
9797
},
9898
c, 1024L);
9999
#ifdef WCONV
100-
// expected-warning-re@-2{{implicit conversion changes signedness: '__private char' to 'unsigned {{int|long}}'}}
100+
// expected-warning-re@-2{{implicit conversion changes signedness: 'char' to 'unsigned {{int|long}}'}}
101101
#endif
102102
#define UINT_MAX 4294967295
103103

0 commit comments

Comments
 (0)