Skip to content

Commit 32301c3

Browse files
committed
Fix the test started to fail with the change
1 parent c5ad9ac commit 32301c3

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

source/slang/slang-check-expr.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -2069,17 +2069,16 @@ IntVal* SemanticsVisitor::tryConstantFoldExpr(
20692069
if (!isValidCompileTimeConstantType(substType))
20702070
return nullptr;
20712071

2072-
IntVal* val = nullptr;
2073-
if (auto floatLitExpr = typeCastOperand.as<FloatingPointLiteralExpr>())
2072+
IntVal* val = tryConstantFoldExpr(typeCastOperand, kind, circularityInfo);
2073+
if (!val)
20742074
{
2075-
// When explicitly casting from float type to integer type, let's fold it as an integer
2076-
// value.
2077-
const IntegerLiteralValue value = IntegerLiteralValue(floatLitExpr.getExpr()->value);
2078-
val = m_astBuilder->getIntVal(substType, value);
2079-
}
2080-
else
2081-
{
2082-
val = tryConstantFoldExpr(typeCastOperand, kind, circularityInfo);
2075+
if (auto floatLitExpr = typeCastOperand.as<FloatingPointLiteralExpr>())
2076+
{
2077+
// When explicitly casting from float type to integer type, let's fold it as
2078+
// an integer value.
2079+
const IntegerLiteralValue value = IntegerLiteralValue(floatLitExpr.getExpr()->value);
2080+
val = m_astBuilder->getIntVal(substType, value);
2081+
}
20832082
}
20842083

20852084
if (val)

tests/diagnostics/attribute-error.slang

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Tests reflection of user defined attributes.
44

5-
//DIAGNOSTIC_TEST:REFLECTION:-stage compute -entry main -target hlsl
5+
//TEST:SIMPLE(filecheck=REFLECTION):-stage compute -entry main -target hlsl
66

77
[__AttributeUsage(_AttributeTargets.Struct)]
88
struct MyStructAttribute
@@ -16,9 +16,11 @@ struct DefaultValueAttribute
1616
int iParam;
1717
};
1818

19+
//REFLECTION:([[# @LINE+1]]): error 30019: expected an expression of type 'float', got 'String'
1920
[MyStruct(0, "stringVal")] // attribute arg type mismatch
2021
struct A
2122
{
23+
//REFLECTION:([[# @LINE+1]]): error 31002: attribute 'MyStruct' is not valid here
2224
[MyStruct(0, 10.0)] // attribute does not apply to this construct
2325
float x;
2426
[DefaultValue(2.0)] // attribute arg type mismatch
@@ -31,4 +33,4 @@ ParameterBlock<A> param;
3133
void main(
3234
uint3 dispatchThreadID : SV_DispatchThreadID)
3335
{
34-
}
36+
}

0 commit comments

Comments
 (0)