Skip to content

Commit a5ee747

Browse files
committed
Add regression test.
1 parent 8a7c053 commit a5ee747

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

source/slang/slang-check-conversion.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,13 @@ bool SemanticsVisitor::coerceIntLitToBaseType(
11281128
case BaseType::UInt8:
11291129
cost = kConversionCost_InRangeIntLitSignedToUnsignedConversion;
11301130
break;
1131+
case BaseType::Float:
1132+
case BaseType::Double:
1133+
cost = kConversionCost_IntegerToFloatConversion;
1134+
break;
1135+
case BaseType::Half:
1136+
cost = kConversionCost_IntegerToHalfConversion;
1137+
break;
11311138
default:
11321139
cost = kConversionCost_InRangeIntLitConversion;
11331140
break;
@@ -1418,15 +1425,12 @@ bool SemanticsVisitor::_coerce(
14181425
return true;
14191426
}
14201427

1428+
if (auto toLitType = as<IntLiteralType>(toType))
1429+
toType = (BasicExpressionType*)toLitType->getProperType();
1430+
14211431
if (auto fromIntLitType = as<IntLiteralType>(fromType))
14221432
{
1423-
auto toBasicType = as<BasicExpressionType>(toType);
1424-
if (!toBasicType)
1425-
{
1426-
if (auto toLitType = as<IntLiteralType>(toType))
1427-
toBasicType = (BasicExpressionType*)toLitType->getProperType();
1428-
}
1429-
if (toBasicType)
1433+
if (auto toBasicType = as<BasicExpressionType>(toType))
14301434
{
14311435
return coerceIntLitToBaseType(
14321436
fromIntLitType,
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
//TEST:SIMPLE(filecheck=CHECK):-target hlsl -entry computeMain -profile cs_6_0
3+
4+
RWStructuredBuffer<int> outputBuffer;
5+
6+
[numthreads(1,1,1)]
7+
void computeMain()
8+
{
9+
// CHECK: 4001
10+
int8_t a = 1;
11+
// we should resolve + to call +<int32_t> here.
12+
outputBuffer[0] = a + 4000;
13+
}

0 commit comments

Comments
 (0)