@@ -287,6 +287,10 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
287287 return true ;
288288 }
289289
290+ case CK_IntegralComplexToReal:
291+ case CK_FloatingComplexToReal:
292+ return this ->emitComplexReal (SubExpr);
293+
290294 case CK_ToVoid:
291295 return discard (SubExpr);
292296
@@ -2030,7 +2034,7 @@ bool ByteCodeExprGen<Emitter>::dereference(
20302034 }
20312035
20322036 if (LV->getType ()->isAnyComplexType ())
2033- return visit (LV);
2037+ return this -> delegate (LV);
20342038
20352039 return false ;
20362040}
@@ -2767,22 +2771,10 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
27672771 if (!this ->visit (SubExpr))
27682772 return false ;
27692773 return DiscardResult ? this ->emitPop (*T, E) : this ->emitComp (*T, E);
2770- case UO_Real: { // __real x
2774+ case UO_Real: // __real x
27712775 if (T)
27722776 return this ->delegate (SubExpr);
2773- if (!this ->visit (SubExpr))
2774- return false ;
2775- if (!this ->emitConstUint8 (0 , E))
2776- return false ;
2777- if (!this ->emitArrayElemPtrPopUint8 (E))
2778- return false ;
2779-
2780- // Since our _Complex implementation does not map to a primitive type,
2781- // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2782- if (!SubExpr->isLValue ())
2783- return this ->emitLoadPop (classifyPrim (E->getType ()), E);
2784- return true ;
2785- }
2777+ return this ->emitComplexReal (SubExpr);
27862778 case UO_Imag: { // __imag x
27872779 if (T) {
27882780 if (!this ->discard (SubExpr))
@@ -2953,6 +2945,29 @@ bool ByteCodeExprGen<Emitter>::emitPrimCast(PrimType FromT, PrimType ToT,
29532945 return false ;
29542946}
29552947
2948+ // / Emits __real(SubExpr)
2949+ template <class Emitter >
2950+ bool ByteCodeExprGen<Emitter>::emitComplexReal(const Expr *SubExpr) {
2951+ assert (SubExpr->getType ()->isAnyComplexType ());
2952+
2953+ if (DiscardResult)
2954+ return this ->discard (SubExpr);
2955+
2956+ if (!this ->visit (SubExpr))
2957+ return false ;
2958+ if (!this ->emitConstUint8 (0 , SubExpr))
2959+ return false ;
2960+ if (!this ->emitArrayElemPtrPopUint8 (SubExpr))
2961+ return false ;
2962+
2963+ // Since our _Complex implementation does not map to a primitive type,
2964+ // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2965+ if (!SubExpr->isLValue ())
2966+ return this ->emitLoadPop (*classifyComplexElementType (SubExpr->getType ()),
2967+ SubExpr);
2968+ return true ;
2969+ }
2970+
29562971// / When calling this, we have a pointer of the local-to-destroy
29572972// / on the stack.
29582973// / Emit destruction of record types (or arrays of record types).
0 commit comments