Skip to content

Commit 8a03b0d

Browse files
committed
fix issues introduced in self review
1 parent adf6cb9 commit 8a03b0d

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,13 +3843,15 @@ static bool handleScalarCast(EvalInfo &Info, const FPOptions FPO, const Expr *E,
38433843
if (!HandleConversionToBool(Original, BoolResult))
38443844
return false;
38453845
uint64_t IntResult = BoolResult;
3846-
Result = APValue(Info.Ctx.MakeIntValue(
3847-
IntResult, Info.Ctx.getIntTypeForBitwidth(64, true)));
3846+
QualType IntType = DestTy->isIntegerType()
3847+
? DestTy
3848+
: Info.Ctx.getIntTypeForBitwidth(64, false);
3849+
Result = APValue(Info.Ctx.MakeIntValue(IntResult, IntType));
38483850
}
38493851
if (DestTy->isFloatingType()) {
38503852
APValue Result2 = APValue(APFloat(0.0));
38513853
if (!HandleIntToFloatCast(Info, E, FPO,
3852-
Info.Ctx.getIntTypeForBitwidth(64, true),
3854+
Info.Ctx.getIntTypeForBitwidth(64, false),
38533855
Result.getInt(), DestTy, Result2.getFloat()))
38543856
return false;
38553857
Result = Result2;

clang/test/SemaHLSL/Types/BuiltinVector/TruncationConstantExpr.hlsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// Note: these tests are a bit awkward because at time of writing we don't have a
66
// good way to constexpr `any` for bool vector conditions, and the condition for
77
// _Static_assert must be an integral constant.
8-
98
export void fn() {
10-
119
// This compiling successfully verifies that the vector constant expression
1210
// gets truncated to an integer at compile time for instantiation.
1311
_Static_assert(((int)1.xxxx) + 0 == 1, "Woo!");

clang/test/SemaHLSL/Types/ElementwiseCastConstantExpr.hlsl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct B2 : B1 {
2727
};
2828

2929
export void fn() {
30-
/*
3130
_Static_assert(((float4)(int[6]){1,2,3,4,5,6}).x == 1.0, "Woo!");
3231

3332
// This compiling successfully verifies that the array constant expression
@@ -80,13 +79,13 @@ export void fn() {
8079
_Static_assert(SB.U[1] == 1000, "Woo!");
8180
_Static_assert(SB.I == 8, "Woo!");
8281
_Static_assert(SB.I2 == 0, "Woo!");
83-
*/
82+
8483
// Make sure we read bitfields correctly
8584
constexpr Base BB = {222.22, {100, 200}, -2, 7};
86-
constexpr int Arr[5] = (int[5])BB;
87-
_Static_assert(Arr[0] == 222, "Woo!");
88-
_Static_assert(Arr[1] == 100, "Woo!");
89-
_Static_assert(Arr[2] == 200, "Woo!");
90-
_Static_assert(Arr[3] == -2, "Woo!");
91-
_Static_assert(Arr[4] == 7, "Woo!");
85+
constexpr int Arr3[5] = (int[5])BB;
86+
_Static_assert(Arr3[0] == 222, "Woo!");
87+
_Static_assert(Arr3[1] == 100, "Woo!");
88+
_Static_assert(Arr3[2] == 200, "Woo!");
89+
_Static_assert(Arr3[3] == -2, "Woo!");
90+
_Static_assert(Arr3[4] == 7, "Woo!");
9291
}

0 commit comments

Comments
 (0)