@@ -280,6 +280,10 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
280280 return true ;
281281 }
282282
283+ case CK_IntegralComplexToReal:
284+ case CK_FloatingComplexToReal:
285+ return this ->emitComplexReal (SubExpr);
286+
283287 case CK_ToVoid:
284288 return discard (SubExpr);
285289
@@ -2023,7 +2027,7 @@ bool ByteCodeExprGen<Emitter>::dereference(
20232027 }
20242028
20252029 if (LV->getType ()->isAnyComplexType ())
2026- return visit (LV);
2030+ return this -> delegate (LV);
20272031
20282032 return false ;
20292033}
@@ -2760,21 +2764,9 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
27602764 if (!this ->visit (SubExpr))
27612765 return false ;
27622766 return DiscardResult ? this ->emitPop (*T, E) : this ->emitComp (*T, E);
2763- case UO_Real: { // __real x
2767+ case UO_Real: // __real x
27642768 assert (!T);
2765- if (!this ->visit (SubExpr))
2766- return false ;
2767- if (!this ->emitConstUint8 (0 , E))
2768- return false ;
2769- if (!this ->emitArrayElemPtrPopUint8 (E))
2770- return false ;
2771-
2772- // Since our _Complex implementation does not map to a primitive type,
2773- // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2774- if (!SubExpr->isLValue ())
2775- return this ->emitLoadPop (classifyPrim (E->getType ()), E);
2776- return true ;
2777- }
2769+ return this ->emitComplexReal (SubExpr);
27782770 case UO_Imag: { // __imag x
27792771 assert (!T);
27802772 if (!this ->visit (SubExpr))
@@ -2941,6 +2933,29 @@ bool ByteCodeExprGen<Emitter>::emitPrimCast(PrimType FromT, PrimType ToT,
29412933 return false ;
29422934}
29432935
2936+ // / Emits __real(SubExpr)
2937+ template <class Emitter >
2938+ bool ByteCodeExprGen<Emitter>::emitComplexReal(const Expr *SubExpr) {
2939+ assert (SubExpr->getType ()->isAnyComplexType ());
2940+
2941+ if (DiscardResult)
2942+ return this ->discard (SubExpr);
2943+
2944+ if (!this ->visit (SubExpr))
2945+ return false ;
2946+ if (!this ->emitConstUint8 (0 , SubExpr))
2947+ return false ;
2948+ if (!this ->emitArrayElemPtrPopUint8 (SubExpr))
2949+ return false ;
2950+
2951+ // Since our _Complex implementation does not map to a primitive type,
2952+ // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2953+ if (!SubExpr->isLValue ())
2954+ return this ->emitLoadPop (*classifyComplexElementType (SubExpr->getType ()),
2955+ SubExpr);
2956+ return true ;
2957+ }
2958+
29442959// / When calling this, we have a pointer of the local-to-destroy
29452960// / on the stack.
29462961// / Emit destruction of record types (or arrays of record types).
0 commit comments