@@ -294,6 +294,29 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
294
294
case CK_ToVoid:
295
295
return discard (SubExpr);
296
296
297
+ case CK_IntegralRealToComplex:
298
+ case CK_FloatingRealToComplex: {
299
+ // We're creating a complex value here, so we need to
300
+ // allocate storage for it.
301
+ if (!Initializing) {
302
+ std::optional<unsigned > LocalIndex =
303
+ allocateLocal (CE, /* IsExtended=*/ true );
304
+ if (!LocalIndex)
305
+ return false ;
306
+ if (!this ->emitGetPtrLocal (*LocalIndex, CE))
307
+ return false ;
308
+ }
309
+
310
+ // Init the complex value to {SubExpr, 0}.
311
+ if (!this ->visitArrayElemInit (0 , SubExpr))
312
+ return false ;
313
+ // Zero-init the second element.
314
+ PrimType T = classifyPrim (SubExpr->getType ());
315
+ if (!this ->visitZeroInitializer (T, SubExpr->getType (), SubExpr))
316
+ return false ;
317
+ return this ->emitInitElem (T, 1 , SubExpr);
318
+ }
319
+
297
320
default :
298
321
assert (false && " Cast not implemented" );
299
322
}
@@ -846,6 +869,10 @@ bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
846
869
847
870
if (T->isAnyComplexType ()) {
848
871
unsigned NumInits = E->getNumInits ();
872
+
873
+ if (NumInits == 1 )
874
+ return this ->delegate (E->inits ()[0 ]);
875
+
849
876
QualType ElemQT = E->getType ()->getAs <ComplexType>()->getElementType ();
850
877
PrimType ElemT = classifyPrim (ElemQT);
851
878
if (NumInits == 0 ) {
0 commit comments