File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,7 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
343
343
}
344
344
345
345
case CK_IntegralToBoolean:
346
+ case CK_BooleanToSignedIntegral:
346
347
case CK_IntegralCast: {
347
348
if (DiscardResult)
348
349
return this ->discard (SubExpr);
@@ -362,7 +363,12 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
362
363
363
364
if (FromT == ToT)
364
365
return true ;
365
- return this ->emitCast (*FromT, *ToT, CE);
366
+ if (!this ->emitCast (*FromT, *ToT, CE))
367
+ return false ;
368
+
369
+ if (CE->getCastKind () == CK_BooleanToSignedIntegral)
370
+ return this ->emitNeg (*ToT, CE);
371
+ return true ;
366
372
}
367
373
368
374
case CK_PointerToBoolean:
Original file line number Diff line number Diff line change @@ -61,3 +61,12 @@ namespace {
61
61
typedef float __attribute__ ((vector_size(16 ))) VI42;
62
62
constexpr VI42 A2 = A; // expected-error {{must be initialized by a constant expression}}
63
63
}
64
+
65
+ namespace BoolToSignedIntegralCast {
66
+ typedef __attribute__ ((__ext_vector_type__(4 ))) unsigned int int4;
67
+ constexpr int4 intsT = (int4)true ;
68
+ static_assert (intsT[0 ] == -1 , " " );// ref-error {{not an integral constant expression}}
69
+ static_assert (intsT[1 ] == -1 , " " );// ref-error {{not an integral constant expression}}
70
+ static_assert (intsT[2 ] == -1 , " " );// ref-error {{not an integral constant expression}}
71
+ static_assert (intsT[3 ] == -1 , " " );// ref-error {{not an integral constant expression}}
72
+ }
You can’t perform that action at this time.
0 commit comments